How To: Programming in Python

Python is getting more popular in the open source world.Many open source packages are written exclusively in python.The famous linux distribution “ubuntu” is also embeding python in its core parts.It is very good language to get into the computer programming.This tutorial will introduce you to the python programming language.

What is python?
Python is an interpreted dynamic programming language created by Guido van Rossum in 1990.Python is an open source project and managed by Python software foundation. It is also supported over various platforms that includes windows, Mac and Unix. Python being highly readable language supports object oriented, structural, functional and aspect oriented programming.

Why python?
It is very easy to learn python. What makes python easy to learn is its interactive interpreter, simple syntax and flexible typing.Program development using Python is 5-10 times faster than using C/C++, and 3-5 times faster than using Java.Interactive interpreter produces faster results,so that user can speed up the learning process.It doesn’t require use of curly braces and semicolon as often like C and java which is beneficial in remembering the code.

IDLE (Interactive interpreter)
Python programs are executed with help of interpreter that lets you run your python scripts. If you are running windows then you don’t have python pre-installed. So that leaves you the choice to download official python from python or from the Active state at activestate .

You can download the installer as per your operating system. Follow the installation instructions mentioned in python’s official website or from Active state. Windows installation is very easy, installer takes care of everything. After installation, you will find IDLE, Module docs, Command line version and help document installed on your computer.

In windows you can start the python interpreter by Start Menu>Run>python or From the programs menu. With RUN option command line version will start while from programs menu you can choose between IDLE and Command line version. Both will start in interpreter mode with the (“>>> “) symbol, it prints out version number and copyright notice. That means you are all set to program in python.

To exit from the command line version you have to type :

import sys; sys.exit( )

This will exits you from command line interpreter. If you are using IDLE then you can use File Menu>Exit.

Hello World!

Every programming text starts its first program with Hello World example. So let’s keep the tradition and let’s cut some code, type the following code on the interpreter or you can type the program in text editor (e. g Notepad) then save the file with .Now open it in the IDLE, this will open in the new browser window. Now in this window you can see the RUN menu, go to Run Module. That will produce the output of your program in the IDLE.


# This is comment 
Print "Hello World"


At first interpreter checks the first line which is comment. Any text after the # is considered as comment.Then interpreter prints the message hello world. Please note that python doesn’t have the separate header files like C or C++.

Now let’s take a look at following code


a= input("Type in a Number:") 
print "You typed no. =", a 


Here, input function is used to accept the numerical value from user. If you want to process the string from the user then use raw_input instead of input.It is very difficult to explain every details of the language.To learn more about strings,functions,lists and files go through “How to Think Like a Computer Scientist ( Python Version )”.


  • Advanced programming techniques : – Once you find yourself comfortable with the text processing. You might be interested in creating your own modules or the standalone executable to distribute your application.
  • PY2EXE : -This application allows you to convert your python program into windows executable. This program is created by Thomas Heller. You can download it from py2exe Or you can try this gordan millers installer .

Python Resources
Here are some resources that can answer any of your python questions. First check official FAQ at  python . If you downloaded the active python from activestate then be sure to join the official activepython mailing list. You can download the beginner friendly Dive into python tutorial. Diveintopython and also refer to Non-programmers tutorial for Python, these tutorials are also bundled inside the help documentation of the Active state.

More Python Tutorials

Some other references are:

  • [1] How to Think Like a Computer Scientist ( Python Version )
  • [2] Python Programming on Win32 by Mark Hammond
  • [3] Core Python Programming by Wesley Chun

I hope the information above helped.If you have any questions or suggestions to improve the tutorial please feel free to write comment on it.