Deitel & Associates, Inc. Logo

Back to
digg.png delicious.png blinkit.png furl.png
Internet & World Wide Web How to Program, 3/e
Internet & World Wide Web How to Program, 3/e

© 2004
pages: 1420

Amazon logo

This tutorial presents an introduction to Python—the popular, cross-platform, object-oriented programming language. We show how to create and run a simple Python program and how to work interactively with the Python interpreter.
Download the Code Examples
[Note: This tutorial is an excerpt (Section 35.1) of Chapter 35, Python, from our textbook Internet & World Wide Web How to Program, 3/e. This tutorial may refer to other chapters or sections of the book that are not included here. Permission Information: Deitel, Harvey M. and Paul J., INTERNET & WORLD WIDE WEB HOW TO PROGRAM, 3/E, 2004, pp.1242-1246. Electronically reproduced by permission of Pearson Education, Inc., Upper Saddle River, New Jersey.]
35.1   Introduction to Python
Python is an interpreted, cross-platform, object-oriented language that can be used to write large-scale Internet search engines, small administration scripts, GUI applications, CGI scripts and more. The creator of the language, Guido van Rossum, combined a clean syntax with popular elements from several existing languages to produce Python.
Python is a freely distributed technology whose open-source nature has encouraged a wide base of developers to submit modules that extend the language. Using Python's core modules and those available for free on the Web, programmers can develop applications that accomplish a great variety of tasks. Python's interpreted nature facilitates rapid application development (RAD) of powerful programs. GUI applications, in particular, can be developed and tested quickly using Python's interface to Tcl/Tk (among other GUI toolkits).
For this chapter, we assume that the reader has installed Python 2.0 or later. ActivePython is the industry-standard distribution of Python for Windows, Solaris and Linux platforms. ActivePython is available as a free download from Follow the instructions available at this site to install and configure Python on your computer. Several other distributions of Python are available at
35.1.1  First Python Program
In this section, we examine a simple Python program and explain how to work with the Python programming environment. Python can execute programs stored in files, or can run in interactive mode, where users enter lines of code one at a time. Among other things, interactive mode enables program writers to test small blocks of code quickly and contributes to a relatively rapid development time for most Python projects.
Figure 35.1 is a simple Python program that prints the text Welcome to Python! to the screen. Lines 1-2 contain single-line comments that describe the program. Comments in Python begin with the # character; Python ignores all text in the current line after this character. Line 4 uses the print statement to write the text Welcome to Python! to the screen.
Fig. 35.1 Simple Python program.
1   # Fig. 35.1:
2   # A first program in Python
4   print"Welcome to Python!"

Welcome to Python!
Page 1 | 2 | 3
Read additional Python Tutorials
Return to Tutorial Index