CONTENTS v
9 While loops 75
9.1 Examples
vi CONTENTS
1.4. TYPING THINGS IN 5
8 CHAPTER 1. GETTING STARTED
10 CHAPTER 1. GETTING STARTED
6. Ask the user to enter a number x
2.5. EXERCISES 15
20
22
4.4. ELIF
4.5. EXERCISES
5.3. SWAPPING 35
Example 1
36 CHAPTER 5. MISCELLANEOUS TOPICS I
38 CHAPTER 5. MISCELLANEOUS TOPICS I
a condition of an if statement, you can put a print statement(print)nto(printthe)-356(if)-356(block(printto(prints
40
42
48
6.11. EXERCISES
6.11. EXERCISES
7.6. EXAMPLES 61
72 CHAPTER 8. MORE WITH LISTS
9.1. EXAMPLES 77
Example 4 We canLmhi [(W)92(loop(W)92(toLmimicLfor(W)92(loop,(W)4(loop,shown(loop,belowTd [43(Both(loop,(
9.4. THE ELSE STATEMENT 79
Example 1
82
88 CHAPTER 10. MISCELLANEOUS TOPICS II
list The list function takes something that can be convertel into a list and makes into a list.
10.2. BOOLEANS 89
Example 4
90
11.eWOUNTING WORDS
106
112 CHAPTER 12. TEXT FILES
CHAPTER 13. FUNCTIONS
Ctal.3g 14
130
132 CHAPTER 14. OBJECT-ORIENTED PROGRAMMING
14.3 Inheritance
In object-oriented programming there is a concept called inheritance where you can create a class
that builds off of another class. When you do this, the new class gets all of the variables and
methods of the class it is i.636 0ing from (called the base class). It can then define add 0ional variables
14.5. A TIC-TAC-TOE EXAMPLE 137
138 CHAPTER 14. OBJECT-ORIENTED PROGRAMMING
146 CHAPTER 15. GUI PROGRAMMING WITH TKINTER
160
164 CHAPTER 16. GUI PROGRAMMING II
17.10.
176
18.2. THE PYTHON IMAGING LIBRARY
18.2. THE PYTHON IMAGING LIBRARY 181
putdata
Part III
Intermediate Topics
183
192
CHAPTER 20. USEFUL MODULES
21.2. SYNTAX 211
REGULAR
222 CHAPTER 22. MATH
Chapter 23
24.3. GROUPING THINGS 239
24.3 Grouping things
The groupby
Chapter 25