Introduction » Program Execution »


Program Execution

History of Python TableOfContents The Basics

Python has two modes for program execution: interpreted (or normal mode) and interactive.

Interpreted Mode

A Python program is constructed as a text file containing the instructions to be executed. The following is a simple example of a Python program.

# Classic hello world program in Python.

print "Hello World"
print "How are you today?"

Main Routine

Every program must have a unique starting point; a first statement to be executed. In Java, C and C++, the starting point is the first statement within the main() routine.

In Python, the first statement to be executed, is the first statement in the file at the global level (outside of all functions and methods). In the above example, the first “print” statement will be the first statement executed.


At the command line:


Under UNIX,

  • include the following as the first line in the text file
  • then make the file an executable
%> chmod +x
  • execute the actual program

Interactive Mode

History of Python TableOfContents The Basics

© 2006 - 2008: Rance Necaise - Page last modified on May 19, 2010, at 11:23 AM