Page Contents (hide)
Python has two modes for program execution: interpreted (or normal mode) and interactive.
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.
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:
python mypgm.py
Under UNIX,
#!/usr/bin/python
%> chmod +x mypgm.py
%> mypgm.py