From Python for Java Programmers

Book: Creating Python Programs

Page Contents (hide)

Python has two modes for executing programs. The first is the “normal” or interpreted mode in which a Python script or source file is executed via an interpretor. The interactive mode provides a command shell for entering and executing single statments or small segments of code.

Normal Mode

Python is an interpreted language and was originally designed for scripting tasks. A Python program is commonly constructed by using a text editor or Python IDE to create a text file containing the instructions. The text file or source file, which should have a .py extension, is then executed using a Python interpretor.

Assume the following program was created and stored in the text file hello.py.

name = raw_input( "What is your name? " )
print 'Hello ' + name
 

To execute the program, enter python hello.py

Interactive Mode

Retrieved from http://python4java.necaise.org/Book/CreatingPythonPrograms
Page last modified on August 04, 2006, at 04:32 PM