Previous | Next


The Python interpreter is responsible to execute a series of Python commands and the python script that you are going to write pretty soon.

Just issue any command at the command prompt (>>>) and press enter. Python interpreter will take care of all the process. Often, the result is immediate.

Starting the interactive interpreter in Windows

To start the interactive interpreter, type the following command in windows command prompt:

C:\>python

When you start up Python, you get a prompt similar to the following:

Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

 

Starting the interactive interpreter in Linux/Unix

To start the interactive interpreter, type the following command in linux/unix shell:

$ python

When you start up Python, you get a prompt similar to the following:

Python 2.7.3 (default, Apr 10 2012, 23:31:26)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

 

Write your first Python script

Let’s try to write few basic python scripts on the interpreter to experience how it works.

To print a line of string:

>>> print "Hello World!"
Hello World!

To add 2 numeric value:

>>> 10 + 8
18

To print decimal value of a hexadecimal number:

>>> 0xAB
171


Previous | Next