< BACKMake Note | BookmarkCONTINUE >
156135250194107072078175030179198180024228156016206217188240240204173118092013151098099180

Exercises

1-1. Installing Python. Download the Python software or load it from the CD-ROM, and install it on your system.

1-2. Executing Python. How many different ways are there to run Python?

1-3. Python Standard Library.

  1. (a) Find where the Python executables and standard library modules are installed on your system.

  2. (b) Take a look at some of the standard library files, for example, string.py. It will help you get acclimated to looking at Python scripts.

1-4. Interactive Execution. Start the Python interactive interpreter. You can invoke it by typing in its full pathname or just its name (python or python.exe) if you haveinstalled its location in your search path. (You can alsouse the Python interpreter compiled in Java [jpython or jpython.exe] if you wish.) The startup screen should look like the ones depicted in this chapter. When you see the ">>>," that means the interpreter is ready to accept your Python commands.

Try entering the command for the famous Hello World! program by typing print "Hello World!," then exit the interpreter. On Unix systems, Ctrl-D will send the EOF signal to terminate the Python interpreter, and on DOS systems, the keypress is Ctrl-Z. Exiting from windows in graphical user environments like the Macintosh, PythonWin or IDLE on Windows, or IDLE on Unix can be accomplished by simply closing their respective windows.

1-5. Scripting. As a follow-up to Exercise 1–4, create "Hello World!" as a Python script that does exactly the same thing as the interactive exercise above. If you are using the Unix system, try setting up the automatic startup line so that you can run the program without invoking the Python interpreter.

1-6. Scripting. Create a script that displays your name, age, favorite color, and a bit about you (background, interests, hobbies, etc.) to the screen using the print statement.


Last updated on 9/14/2001
Core Python Programming, © 2002 Prentice Hall PTR

< BACKMake Note | BookmarkCONTINUE >

© 2002, O'Reilly & Associates, Inc.