0% found this document useful (0 votes)
3 views15 pages

Introduction To Python

Python is a high-level, general-purpose programming language created by Guido van Rossum in 1991, known for its emphasis on code readability and efficiency. It supports multiple programming paradigms and is available in two major versions: Python 2 and Python 3. Key features include being interpreted, platform-independent, free and open-source, and having a rich standard library, making it a popular choice among programmers.

Uploaded by

srichu007pk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views15 pages

Introduction To Python

Python is a high-level, general-purpose programming language created by Guido van Rossum in 1991, known for its emphasis on code readability and efficiency. It supports multiple programming paradigms and is available in two major versions: Python 2 and Python 3. Key features include being interpreted, platform-independent, free and open-source, and having a rich standard library, making it a popular choice among programmers.

Uploaded by

srichu007pk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction To Python

●​

●​Python is a widely used general-purpose, high-level


programming language.

●​It was created by Guido van Rossum in 1991 and further


developed by the Python Software Foundation.
●​It was designed with an emphasis on code readability, and its
syntax allows programmers to express their concepts in fewer
lines of code.

●​Python is a programming language that lets you work quickly


and integrate systems more efficiently.

●​There are two major Python versions:


Python 2 and Python 3. Both are quite different.
Beginning with Python Programming

Finding an Interpreter
Before we start Python programming, we need to have an
interpreter to interpret and run our programs.
●​Windows: There are many interpreters available freely to run
Python scripts like IDLE (Integrated Development
Environment), which comes bundled with the Python software
downloaded from http://python.org/.

●​Linux: Python comes preinstalled with popular Linux distros


such as Ubuntu and Fedora. To check which version of Python
you’re running, type “python” in the terminal emulator. The
interpreter should start and print the version number.

●​macOS: Generally, Python 2.7 comes bundled with macOS.


You’ll have to manually install Python 3
from http://python.org/.
Writing our First Program

Just type in the following code after you start the interpreter.
Python
# Script Begins

print("Good")

# Scripts Ends

Output:
Good

Let’s analyze the script line by line.

Line 1: [# Script Begins]


In Python, comments begin with a #. This statement is ignored by
the interpreter and serves as documentation for our code.

Line 2: [print(“Good”)]

To print something on the console, print() function is used. This


function also adds a newline after our message is printed(unlike
in C). Note that in Python 2, “print” is not a function but a
keyword and therefore can be used without parentheses.
However, in Python 3, it is a function and must be invoked with
parentheses.

Line 3: [# Script Ends]


This is just another comment like in Line 1.
Reason for increasing popularity

1.​Emphasis on code readability, shorter codes, ease of writing


2.​Programmers can express logical concepts in fewer lines of code
in comparison to languages such as C++ or Java.
3.​Python supports multiple programming paradigms, like
object-oriented, imperative and functional programming or
procedural.
4.​There exists inbuilt functions for almost all of the frequently
used concepts.
5.​Philosophy is “Simplicity is the best”.
LANGUAGE FEATURES
●​Interpreted
o​There are no separate compilation and execution steps like
C and C++.
o​Directly run the program from the source code.
o​Internally, Python converts the source code into an
intermediate form called bytecodes which is then
translated into native language of specific computer to run
it.
o​No need to worry about linking and loading with libraries,
etc.
●​Platform Independent
o​Python programs can be developed and executed on
multiple operating system platforms.
o​Python can be used on Linux, Windows, Macintosh,
Solaris and many more.
●​Free and Open Source; Redistributable
●​High-level Language
o​In Python, no need to take care about low-level details
such as managing the memory used by the program.
●​Simple
o​Closer to English language;Easy to Learn
o​More emphasis on the solution to the problem rather than
the syntax
●​Embeddable
o​Python can be used within C/C++ program to give
scripting capabilities for the program’s users.
●​Robust:
o​Exceptional handling features
o​Memory management techniques in built
●​Rich Library Support
o​The Python Standard Library is very vast.
o​Known as the “batteries included” philosophy of Python
;It can help do various things involving regular
expressions, documentation generation, unit testing,
threading, databases, web browsers, CGI, email, XML,
HTML, WAV files, cryptography, GUI and many more.
o​Besides the standard library, there are various other
high-quality libraries such as the Python Imaging
Library which is an amazingly simple image manipulation
library.

Python vs JAVA
Python Java
Dynamically Typed Statically Typed
●​No need to declare ●​All variable names (along with
anything. An assignment their types) must be explicitly
statement binds a name to declared. Attempting to assign
an object, and the object an object of the wrong type to a
can be of any type. variable name triggers a type
●​No type casting is exception.
required when using ●​Type casting is required when
container objects using container objects.

Concise Express much in


Verbose Contains more words
limited words
Python Java
Compact Less Compact

Uses Indentation for


Uses braces for structuring code
structuring code

An indentation is the space at the beginning of a line of writing


when it starts further away from the edge of the paper than all
the other lines.

The classical Hello World program illustrating the relative


verbosity of a Java Program and Python Program
Java Code

public class HelloWorld


{
public static void main (String[] args)
{
System.out.println("Hello, world!");
}
}

Python Code

print("Hello, world!")
Similarity with Java
●​Require some form of runtime on your system (JVM/Python
runtime)
●​Can probably be compiled to executables without the runtime
(this is situational, none of them are designed to work this way)

You might also like