Book » Creating Python Programs »

 

Creating Python Programs

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


Book

© 2006 - 2008: Rance Necaise - Page last modified on August 04, 2006, at 04:32 PM