|
Program ExecutionHistory of Python TableOfContents The Basics Page Contents (hide) Python has two modes for program execution: interpreted (or normal mode) and interactive. Interpreted ModeA 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 RoutineEvery 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 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. ExecutionAt the command line: python mypgm.py
Under UNIX,
#!/usr/bin/python
%> chmod +x mypgm.py
%> mypgm.py
Interactive Mode | |
© 2006 - 2008: Rance Necaise - Page last
modified on May 19, 2010, at 11:23 AM
|