Acknowledgments |
|
xix | |
Introduction What Is Coding And Why Is It Good For Your Kids? |
|
xxi | |
Why Should Kids Learn to Code? |
|
xxii | |
Coding Is Fun |
|
xxii | |
Coding Is a Valuable Job Skill |
|
xxii | |
Where Can Kids Learn to Code? |
|
xxiii | |
How to Use This Book |
|
xxiv | |
Explore! |
|
xxiv | |
Do It Together! |
|
xxv | |
Online Resources |
|
xxv | |
Coding = Solving Problems |
|
xxvi | |
|
1 Python Basics: Get To Know Your Environment |
|
|
1 | (10) |
|
Getting Started with Python |
|
|
3 | (3) |
|
|
4 | (1) |
|
|
5 | (1) |
|
3 Test Python with a Program |
|
|
5 | (1) |
|
Writing Programs in Python |
|
|
6 | (1) |
|
Running Programs in Python |
|
|
6 | (1) |
|
|
7 | (1) |
|
|
8 | (3) |
|
|
8 | (1) |
|
|
9 | (2) |
|
2 Turtle Graphics: Drawing With Python |
|
|
11 | (20) |
|
|
12 | (4) |
|
|
13 | (1) |
|
|
14 | (2) |
|
|
16 | (1) |
|
|
17 | (2) |
|
|
19 | (6) |
|
|
20 | (3) |
|
Changing Background Colors |
|
|
23 | (2) |
|
One Variable to Rule Them All |
|
|
25 | (2) |
|
|
27 | (1) |
|
|
27 | (4) |
|
#1 Changing the Number of Sides |
|
|
27 | (1) |
|
|
28 | (1) |
|
|
28 | (3) |
|
3 Numbers And Variables: Python Does The Math |
|
|
31 | (22) |
|
Variables: Where We Keep Our Stuff |
|
|
32 | (2) |
|
Numbers and Math in Python |
|
|
34 | (8) |
|
|
34 | (1) |
|
|
35 | (1) |
|
Doing Math in the Python Shell |
|
|
36 | (1) |
|
Syntax Errors: What Did You Say? |
|
|
37 | (1) |
|
Variables in the Python Shell |
|
|
38 | (1) |
|
Programming with Operators: A Pizza Calculator |
|
|
39 | (3) |
|
Strings: The Real Characters in Python |
|
|
42 | (2) |
|
Improving Our Color Spiral with Strings |
|
|
44 | (2) |
|
Lists: Keeping It All Together |
|
|
46 | (2) |
|
Python Does Your Homework |
|
|
48 | (2) |
|
|
50 | (2) |
|
|
52 | (1) |
|
|
52 | (1) |
|
|
52 | (1) |
|
4 Loops Are Fun (You Can Say That Again) |
|
|
53 | (24) |
|
Building Your Own for Loops |
|
|
55 | (4) |
|
Using a for Loop to Make a Rosette with Four Circles |
|
|
56 | (2) |
|
Modifying Our for Loop to Make a Rosette with Six Circles |
|
|
58 | (1) |
|
Improving Our Rosette Program with User Input |
|
|
59 | (2) |
|
Game Loops and while Loops |
|
|
61 | (3) |
|
|
64 | (4) |
|
Putting It All Together: Spiral Goes Viral |
|
|
68 | (5) |
|
|
73 | (1) |
|
|
74 | (3) |
|
|
74 | (1) |
|
#2 A Spiral of Family Spirals |
|
|
75 | (2) |
|
|
77 | (28) |
|
|
79 | (2) |
|
|
81 | (4) |
|
|
81 | (3) |
|
|
84 | (1) |
|
|
85 | (6) |
|
|
86 | (2) |
|
|
88 | (3) |
|
|
91 | (1) |
|
Complex Conditions: if, and, or, not |
|
|
92 | (3) |
|
|
95 | (6) |
|
|
96 | (1) |
|
The Value of Character(s) |
|
|
97 | (2) |
|
Our Encoder/Decoder Program |
|
|
99 | (2) |
|
|
101 | (1) |
|
|
102 | (3) |
|
#1 Colorful Rosettes and Spirals |
|
|
102 | (1) |
|
|
102 | (3) |
|
6 Random Fun And Games: Go Ahead, Take A Chance! |
|
|
105 | (36) |
|
|
106 | (3) |
|
|
109 | (7) |
|
|
110 | (1) |
|
|
111 | (2) |
|
|
113 | (1) |
|
|
114 | (2) |
|
|
116 | (3) |
|
|
119 | (7) |
|
|
119 | (1) |
|
|
120 | (1) |
|
|
121 | (2) |
|
|
123 | (2) |
|
|
125 | (1) |
|
Roll the Dice: Creating a Yahtzee-Style Game |
|
|
126 | (6) |
|
|
126 | (1) |
|
|
127 | (1) |
|
|
128 | (1) |
|
|
129 | (3) |
|
|
132 | (4) |
|
|
136 | (2) |
|
|
138 | (3) |
|
#1 Random Sides and Thickness |
|
|
138 | (1) |
|
#2 Realistic Mirrored Spirals |
|
|
139 | (1) |
|
|
139 | (2) |
|
7 Functions: There's A Name For That |
|
|
141 | (34) |
|
Putting Things Together with Functions |
|
|
142 | (4) |
|
|
143 | (1) |
|
|
144 | (2) |
|
Parameters: Feeding Your Function |
|
|
146 | (7) |
|
Smileys at Random Locations |
|
|
146 | (5) |
|
|
151 | (2) |
|
Return: It's What You Give Back That Counts |
|
|
153 | (4) |
|
Returning a Value from a Function |
|
|
153 | (1) |
|
Using Return Values in a Program |
|
|
154 | (3) |
|
|
157 | (11) |
|
Handling Events: TurtleDraw |
|
|
158 | (2) |
|
Listening for Keyboard Events: ArrowDraw |
|
|
160 | (3) |
|
Handling Events with Parameters: ClickSpiral |
|
|
163 | (3) |
|
Taking It One Step Further: ClickandSmile |
|
|
166 | (2) |
|
|
168 | (4) |
|
The draw_kaleido() Function |
|
|
168 | (1) |
|
The draw_spiral() Function |
|
|
169 | (1) |
|
|
170 | (2) |
|
|
172 | (1) |
|
|
173 | (2) |
|
|
173 | (1) |
|
#2 More Ping-Pong Calculations |
|
|
173 | (1) |
|
#3 A Better Drawing Program |
|
|
173 | (2) |
|
8 Timers And Animation: What Would Disney Do? |
|
|
175 | (32) |
|
Getting All GUI with Pygame |
|
|
176 | (9) |
|
Drawing a Dot with Pygame |
|
|
177 | (3) |
|
|
180 | (1) |
|
|
181 | (4) |
|
Timing It Just Right: Move and Bounce |
|
|
185 | (16) |
|
|
186 | (2) |
|
Animating a Smiley with the Clock Class |
|
|
188 | (2) |
|
Bouncing a Smiley Off a Wall |
|
|
190 | (7) |
|
Bouncing a Smiley Off Four Walls |
|
|
197 | (4) |
|
|
201 | (2) |
|
|
203 | (4) |
|
|
203 | (1) |
|
|
203 | (2) |
|
|
205 | (2) |
|
9 User Interaction: Get Into The Game |
|
|
207 | (24) |
|
Adding Interaction: Click and Drag |
|
|
208 | (7) |
|
|
208 | (3) |
|
|
211 | (4) |
|
Advanced Interaction: Smiley Explosion |
|
|
215 | (9) |
|
|
215 | (3) |
|
|
218 | (2) |
|
|
220 | (1) |
|
Bigger and Smaller Smileys |
|
|
221 | (1) |
|
|
222 | (2) |
|
|
224 | (3) |
|
Detecting Collisions and Removing Sprites |
|
|
224 | (2) |
|
|
226 | (1) |
|
|
227 | (1) |
|
|
228 | (3) |
|
|
228 | (1) |
|
|
229 | (1) |
|
|
229 | (2) |
|
10 Game Programming: Coding For Fun |
|
|
231 | (32) |
|
Building a Game Skeleton: Smiley Pong, Version 1.0 |
|
|
232 | (13) |
|
Drawing a Board and Game Pieces |
|
|
234 | (1) |
|
|
235 | (6) |
|
|
241 | (2) |
|
|
243 | (2) |
|
Adding Difficulty and Ending the Game: Smiley Pong, Version 2.0 |
|
|
245 | (7) |
|
|
246 | (1) |
|
|
246 | (1) |
|
|
247 | (3) |
|
|
250 | (2) |
|
Adding More Features: SmileyPop v2.0 |
|
|
252 | (8) |
|
|
252 | (2) |
|
Tracking and Displaying Player Progress |
|
|
254 | (3) |
|
|
257 | (3) |
|
|
260 | (1) |
|
|
261 | (2) |
|
|
261 | (1) |
|
|
262 | (1) |
|
|
262 | (1) |
|
A Python Setup For Windows, Mac, And Linux |
|
|
263 | (16) |
|
|
264 | (7) |
|
|
264 | (1) |
|
|
265 | (4) |
|
|
269 | (2) |
|
|
271 | (5) |
|
|
271 | (1) |
|
|
272 | (3) |
|
|
275 | (1) |
|
|
276 | (3) |
|
B Pygame Setup For Windows, Mac, And Linux |
|
|
279 | (10) |
|
|
280 | (4) |
|
|
284 | (3) |
|
Python 2.7 and Pygame 1.9.2 |
|
|
284 | (3) |
|
|
287 | (2) |
|
|
287 | (2) |
|
C Building Your Own Modules |
|
|
289 | (6) |
|
Building the colorspiral Module |
|
|
290 | (4) |
|
Using the colorspiral Module |
|
|
291 | (1) |
|
Reusing the colorspiral Module |
|
|
292 | (2) |
|
|
294 | (1) |
Glossary |
|
295 | (6) |
Index |
|
301 | |