Home Page Icon
Home Page
Table of Contents for
Python® For Kids For Dummies®
Close
Python® For Kids For Dummies®
by Brendan Scott
Python For Kids For Dummies
Cover
Cover
Introduction
About This Book
Conventions Used
Foolish Assumptions
Icons Used in This Book
Beyond the Book
Where to Go from Here
Week 1: Slithering into Python
Project 1: Getting Started with Python
Python and Why It’s Wonderful
Who’s Using Python
Making Things with Python
Understanding This Book’s Pedagogical Approach
Install Python on Mac OSX
Install Python on Windows
Install Python for Linux
Pin Python to Your Start Menu
Start the Python Interpreter
Use Python’s Built-In Documentation
Put the Kibosh on the Python Interpreter
Find Python Documentation Online
Join the Broader Python Community
Handle Problems
Learn How to Learn
Summary
Project 2: Hello World!
Write Hello World!
Spot and Fix Errors
Work with Literals
Literally Save Your Strings in Variables
Interrupt a Program
Drive Up to Python Keywords
Many Loop, Much Hello
Fill the Screen with Greetings
Make Python Count
Summary
Week 2: Building Guessing Games
Project 3: Guessing Game
Plan the Game
Get Input from the Player
Ask for Input
Make Sure Things Are Equal
Call the Operators
Divide in Python
Compare the Guess to a Number
Compare the Player’s Guess to the Computer’s Number
Tell Players If the Guess Is Wrong
Keep Asking Until the Player Guesses Correctly
Make Python Think of a Random Number
Use Namespaces
Finish Your Guessing Game
Summary
Project 4: Set Up Your Coding Environment
Use the Default Development Environment
Start IDLE
Stash Some IDLE Tricks
Use the IDLE Editor Window
Write Comments in Your Files
Insert Hash Comments
Save Your Shell Contents
Comment Out Code
Indent and Dedent Your Code
Summary
Project 5: A Better Guessing Game
Handle Your Functions
Naming Functions
Add Function Help Text
Make a Function Stub
Rework Your Guessing Game
Find a Logic Problem
Solve the Logic Problem
Notice Double Use of computers_number
Understand How Scope Works
Communicate with Your Function
Send Information to a Function
Give Some Arguments a Default Value
Communicate from the Function
Add a Score
Let the User Quit
The Complete Code
Summary
Week 3: Creating Word Games
Project 6: Hacker Speaker: 1337 Sp34k3r
Waiter, There’s An Object In My String
Dot Your Objects’ Attributes
Meet the List
Go Through the Elements of a List
Create Your Own List
Create a List on Steroids
Test Whether an Element’s In a List
Planning Your Elite Hacker Speaker
Set Up Your File
Make Code Letter Substitutions
Replace a Letter
Let the User Enter a Message
Define Letter Substitutions
Apply all the Substitutions
Use print to Debug the Code
Debug with IDLE’s Debugger
Summary
Project 7: Cryptopy
Slice Off Those Dud Characters
Make a Substitution Table
Set Up Your Cipher
Use the Dictionary
Create an Encryption Dictionary
Use a join
Rewrite the Encryption Function
Write the Decryption Function
Encrypt a Text File
Encrypt and Decrypt from a File
Decrypt from Your Shell
Change the Code to Decrypt Too
The Complete Code
Summary
Project 8: Silly Sentences
Insert Format Strings
Have the Right Number of Values
Use the Tuple Data Type
Get Started on Your Silly Sentences
Fill the Template
Add More Words
The Complete Code
Summary
Week 4: Stepping Up to Object-Oriented Programming
Project 9: Address Book
Your First Class Objects
Create a Class
Create an Instance
Create Class and Instance Attributes
Plan Your Address Book
Set Up Your File and Create a Class
Add Your First Person
Instantiate an Instance Using __init__
Create a Function to Print the Instance
Use __repr__ Magic
Initialize the AddressBook Instance
Find Pickle Power
Add a save Function
Loading a Saved Pickle in the Same Application
Test the load Method
Add an Interface
Fill in the Methods
The Complete Code
Summary
Project 10: Math Trainer
Planning Your Math Trainer
Setting Up
Create Questions
Ask Lots of Questions in a Row
Print Out a Times Table
Print Multiple Tables Across the Screen
Start on the User Interface
Add Quit Functionality
Polishing It Off
Summary
About the Author
Cheat Sheet
Connect with Dummies
End User License Agreement
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Next
Next Chapter
Introduction
Python® For Kids For Dummies®
Visit
www.dummies.com/cheatsheet/pythonforkids
to view this book's cheat sheet.
Table of Contents
Cover
Introduction
About This Book
Conventions Used
Foolish Assumptions
Icons Used in This Book
Beyond the Book
Where to Go from Here
Week 1: Slithering into Python
Project 1: Getting Started with Python
Python and Why It’s Wonderful
Who’s Using Python
Making Things with Python
Understanding This Book’s Pedagogical Approach
Install Python on Mac OSX
Install Python on Windows
Install Python for Linux
Pin Python to Your Start Menu
Start the Python Interpreter
Use Python’s Built-In Documentation
Put the Kibosh on the Python Interpreter
Find Python Documentation Online
Join the Broader Python Community
Handle Problems
Learn How to Learn
Summary
Project 2: Hello World!
Write
Hello World!
Spot and Fix Errors
Work with Literals
Literally Save Your Strings in Variables
Interrupt a Program
Drive Up to Python Keywords
Many Loop, Much Hello
Fill the Screen with Greetings
Make Python Count
Summary
Week 2: Building Guessing Games
Project 3: Guessing Game
Plan the Game
Get Input from the Player
Ask for Input
Make Sure Things Are Equal
Call the Operators
Divide in Python
Compare the Guess to a Number
Compare the Player’s Guess to the Computer’s Number
Tell Players If the Guess Is Wrong
Keep Asking Until the Player Guesses Correctly
Make Python Think of a Random Number
Use Namespaces
Finish Your Guessing Game
Summary
Project 4: Set Up Your Coding Environment
Use the Default Development Environment
Start IDLE
Stash Some IDLE Tricks
Use the IDLE Editor Window
Write Comments in Your Files
Insert Hash Comments
Save Your Shell Contents
Comment Out Code
Indent and Dedent Your Code
Summary
Project 5: A Better Guessing Game
Handle Your Functions
Naming Functions
Add Function Help Text
Make a Function Stub
Rework Your Guessing Game
Find a Logic Problem
Solve the Logic Problem
Notice Double Use of
computers_number
Understand How Scope Works
Communicate with Your Function
Send Information to a Function
Give Some Arguments a Default Value
Communicate from the Function
Add a Score
Let the User Quit
The Complete Code
Summary
Week 3: Creating Word Games
Project 6: Hacker Speaker: 1337 Sp34k3r
Waiter, There’s An Object In My String
Dot Your Objects’ Attributes
Meet the List
Go Through the Elements of a List
Create Your Own List
Create a List on Steroids
Test Whether an Element’s In a List
Planning Your Elite Hacker Speaker
Set Up Your File
Make Code Letter Substitutions
Replace a Letter
Let the User Enter a Message
Define Letter Substitutions
Apply all the Substitutions
Use
print
to Debug the Code
Debug with IDLE’s Debugger
Summary
Project 7: Cryptopy
Slice Off Those Dud Characters
Make a Substitution Table
Set Up Your Cipher
Use the Dictionary
Create an Encryption Dictionary
Use a
join
Rewrite the Encryption Function
Write the Decryption Function
Encrypt a Text File
Encrypt and Decrypt from a File
Decrypt from Your Shell
Change the Code to Decrypt Too
The Complete Code
Summary
Project 8: Silly Sentences
Insert Format Strings
Have the Right Number of Values
Use the Tuple Data Type
Get Started on Your Silly Sentences
Fill the Template
Add More Words
The Complete Code
Summary
Week 4: Stepping Up to Object-Oriented Programming
Project 9: Address Book
Your First Class Objects
Create a Class
Create an Instance
Create Class and Instance Attributes
Plan Your Address Book
Set Up Your File and Create a Class
Add Your First Person
Instantiate an Instance Using
__init__
Create a Function to Print the Instance
Use
__repr__
Magic
Initialize the
AddressBook
Instance
Find Pickle Power
Add a
save
Function
Loading a Saved Pickle in the Same Application
Test the
load
Method
Add an Interface
Fill in the Methods
The Complete Code
Summary
Project 10: Math Trainer
Planning Your Math Trainer
Setting Up
Create Questions
Ask Lots of Questions in a Row
Print Out a Times Table
Print Multiple Tables Across the Screen
Start on the User Interface
Add Quit Functionality
Polishing It Off
Summary
About the Author
Cheat Sheet
Connect with Dummies
End User License Agreement
Guide
Cover
Table of Contents
Begin Reading
Pages
i
ii
iii
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
316
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset