Datasheet

Chapter 1: A Python Primer
3
In addition to IDLE, you do have other options. On Windows, there is a nice IDE called PythonWin,
developed by Mark Hammond. It can be installed as a full Python distribution from ActiveState ’ s
website (
www.activestate.com ), or you can simply install the win32all package to add PythonWin to a
standard Python for Windows install. PythonWin is a great product, very slick and with all the features
you d expect from an IDE.
Other options include an Eclipse distribution for Python called EasyEclipse for Python. For my money,
I d start out with IDLE, and then as your experience with Python grows, explore other options.
Lexical Structure
Following is a simple Python program. It shows the basic structure of many Python scripts, which is as
follows:
1. Initialize variables (lines 1 – 3).
2. Do some processing (lines 4 – 5).
3. Make decisions and perform actions based on those decisions (lines 6 – 10).
name = “Jim”
age = 42
highschoolGPA = 3.89
enteredName = raw_input(“Enter your name: “)
print “\n\n”
if name == “Jim”:
print “Your age is “, age
print “You had a”, highschoolGPA, “GPA in high school”
if (highschoolGPA > 3):
print “You had better than a 3.0 GPA...good job!”
Keywords
Keywords are words that are reserved they cannot be used as variable names. In the preceding code,
the keyword
if is used multiple times.
c01.indd 3c01.indd 3 6/2/08 12:03:08 PM6/2/08 12:03:08 PM