Python is now days one of the most popular programming languages that is easy to understand, powerful, platform independent as well as open source.

Here are the advantages of Python:

  1. Open source, you can build your own compiler
  2. Platform independent, can run on any operating system
  3. Powerful, can be used for anything like database systems, video games, 3D modelling, web application etc.
  4. Easy to use and understand
  5. Fast in execution

Examples of products developed using Python are:

  1. Google Search Engine
  2. Yahoo Groups
  3. Yahoo Maps
  4. Shopzilla
  5. Battle Ground 2 (Game)
  6. Blender 3D

and many more

To see a comprehensive list, please see the Wiki page

Python Program Execution

Python works on byte code similar to Java and .NET. This means, when you compile your program ( .py file ), it will be converted to byte code instead of machine code ( .pyc file ).

Python Program => Compile => Byte Code => Execution => Operating System

( .py )                                                  ( .pyc )

Python Basics

Using Variables

In Python, we don’t have to declare the data type of the variable explicitly. The data type to the variable is assigned automatically when we assign values to the variables. For example:

x = 5            ( integer declaration )

y = 5.6         ( float declaration )

z = “India”  ( string declaration )


A comment is a statement that we write to explain the purpose of a particular statement or statements in our code. Comments are ignored by compiler and are removed in the output file.

Python support two type of comments:

  1. Single line comment using #
    x = 5       # we just declared an integer
  2. Multi-line comment using “””  ( 3 times ” )
    We are going to declare length and width of rectangle
    and then we calculate its area
    lenth = 5
    width = 6
    area = length * width

Lines and Indentation

Python do not have { } or some other characters for telling the start and end of a block. It uses indentation to denote a child block. For example, a statement like:

if( x > 5 )
   y = 10
   y = 20

is written in Python as:

if x > 5:
   y = 10
   z = 20
   y = 20
   z = 30

Here, we used tabs for the lines y=10 and z=20 to indicate they are part of if block.

Multi-Line Statements

Python by default assumes that each statement should finish on a single line, but we can also span a statement on more than one line like this:

result = a + \
         b + \

Strings can also be used in multiple lines by using “”” ( 3 times ” )

sentance = """A quick brown fox
jumps over the lazy

Multiple statements in single line

We can write multiple statements in one line using ; like this:

x = 5; y = 5; print(x+y)

Multiple assignment

We can assign values to multiple variables in one line like this:

x, y, z = 5, 6, 7
print("%s %s %s" % (x,y,z))

Basic Input-Output

Here is a basic input put program in Python

print("Enter your name : ")
name = input()

print("Hello " + name)