Appendix. Answers to Self-Test Questions

 

Here are the answers to the “Test your knowledge” and “Try it out” questions at the end of each chapter. Of course, there’s sometimes more than one right answer, especially with the “Try it out” questions, but you can use these answers to see if you are on the right track.

Chapter 1: Getting Started

Test your knowledge

1

In Windows, start IDLE by opening the Start menu, and under the Python 2.5 entry, select the IDLE (Python GUI) entry. In Mac OS X, click IDLE in the Dock, or double-click IDLE.app in the Applications folder. In Linux, it depends on which window manager you are using, but usually there is some sort of Applications or Programs menu.

2

print displays some text in the output window (the IDLE shell window, in our first examples).

3

The symbol for multiplication in Python is * (the asterisk symbol).

4

When you run a program, IDLE displays this line:

>>> ======================= RESTART =======================

5

“Executing” a program is another way to say “running” a program.

Try it out

1

>>> print 7 * 24 * 60 (7 days in a week, 24 hours in a day, 60 minutes in an hour).

You should get 10,080 as the answer.

2

Your program should look something like this:

print "My name is Warren Sande."         
print "My birth date is January 1, 1970."
print "My favorite color is blue."       

Chapter 2: Remember This—Memory and Variables

Test your knowledge

1

You tell Python that a variable is a string by putting quotes around it.

2

Chapter 3: Basic Math

Chapter 4: Types of Data

Chapter 5: Input

Chapter 6: GUIs—Graphical User Interfaces

Chapter 7: Decisions, Decisions

Chapter 8: Loop the Loop

Chapter 9: Just for You—Comments

Chapter 10: Game Time

Chapter 11: Nested and Variable Loops

Chapter 12: Collecting Things Together—Lists

Chapter 13: Functions

Chapter 14: Objects

Chapter 15: Modules

Chapter 16: Graphics

Chapter 17: Sprites and Collision Detection

Chapter 18: A New Kind of Input—Events

Chapter 19: Sound

Chapter 20: More GUIs

Chapter 21: Print Formatting and Strings