With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

Book Description

Teach Your Kids to Code is a parent and teacher's guide to teaching basic programming and problem-solving skills.

1. Teach Your Kids to Code: A Parent-Friendly Guide to Python Programming
2. Dedication
7. Acknowledgments
8. Introduction: What Is Coding and Why Is It Good for Your Kids?
1. Why Should Kids Learn to Code?
2. Where Can Kids Learn to Code?
3. How to Use This Book
4. Coding = Solving Problems
9. 1. Python Basics: Get to Know Your Environment
1. Getting Started with Python
2. Writing Programs in Python
3. Running Programs in Python
4. What You Learned
10. 2. Turtle Graphics: Drawing with Python
1. Our First Turtle Program
2. Turtle on a Roll
3. Turtle Roundup
4. Adding a Touch of Color
1. SquareSpiral3.py
2. A Four-Color Spiral
3. Changing Background Colors
5. One Variable to Rule Them All
6. What You Learned
11. 3. Numbers and Variables: Python Does the Math
1. Variables: Where We Keep Our Stuff
2. Numbers and Math in Python
1. Python Numbers
2. Python Operators
3. Doing Math in the Python Shell
4. Syntax Errors: What Did You Say?
5. Variables in the Python Shell
6. Programming with Operators: A Pizza Calculator
3. Strings: The Real Characters in Python
4. Improving Our Color Spiral With Strings
5. Lists: Keeping It All Together
7. What You Learned
12. 4. Loops Are Fun (You Can Say That Again)
1. Rosette.py
2. Building Your Own for Loops
1. Using a for Loop to Make a Rosette with Four Circles
2. Modifying Our for Loop to Make a Rosette with Six Circles
3. Improving Our Rosette Program with User Input
4. Game Loops and while Loops
5. The Family Spiral
6. Putting It All Together: Spiral Goes Viral
7. What You Learned
13. 5. Conditions (What If?)
1. If Statements
2. Meet the Booleans
1. Comparison Operators
2. You’re Not Old Enough!
3. Else Statements
1. OldEnoughOrElse.py
2. Polygons or Rosettes
3. Even or Odd?
4. Elif Statements
5. Complex Conditions: If, and, or, not
6. Secret Messages
1. Messin’ with Strings
2. The Value of Character(s)
3. Our Encoder/Decoder Program
7. What You Learned
14. 6. Random Fun and Games: Go Ahead, Take a Chance!
1. A Guessing Game
2. Colorful Random Spirals
1. Pick a Color, Any Color
2. Getting Coordinated
3. How Big Is Our Canvas?
4. Putting It All Together
3. Rock-Paper-Scissors
4. Pick a Card, Any Card
1. Stacking the Deck
2. Dealing Cards
3. Counting Cards
4. Keeping It Going
5. Putting It All Together
5. Roll the Dice: Creating a Yahtzee-Style Game
1. Setting Up the Game
2. Sorting the Dice
3. Testing the Dice
4. Putting It All Together
6. Kaleidoscope
7. What You Learned
15. 7. Functions: There’s a Name for That
1. Putting Things Together with Functions
1. Smileys at Random Locations
2. Putting it all together
3. RandomSmileys.py
3. Return: It’s What You Give Back That Counts
1. Returning a Value from a Function
2. Using Return Values in a Program
4. A Touch of Interaction
1. Handling Events: TurtleDraw
2. Listening for Keyboard Events: ArrowDraw
3. Handling Events with Parameters: Clickspiral
4. Taking It One Step Further: Clickandsmile
5. ClickKaleidoscope
1. The Draw_Kaleido() Function
2. The Draw_Spiral() Function
3. Putting It All Together
6. What You Learned
16. 8. Timers and Animation: What Would Disney Do?
1. Getting All GUI with Pygame
1. Drawing a Dot with Pygame
2. What’s New in Pygame
3. The Parts of a Game
1. Setting Up
2. Creating a Game Loop
3. Exiting the Program
4. Putting It All Together
2. Timing It Just Right: Move and Bounce
1. Moving a Smiley
2. Animating a Smiley with the Clock Class
3. Bouncing a Smiley Off a Wall
1. Hitting the Wall
2. Changing Direction
3. Putting It All Together
4. Bouncing a Smiley Off Four Walls
1. Horizontal and Vertical Speed
2. Hitting Four Walls
3. Putting It All Together
3. What You Learned
17. 9. User Interaction: Get into the Game
1. Adding Interaction: Click and Drag
1. Clicking for Dots
1. Setup
2. Game Loop: Handling Mouse Clicks
3. Putting It All Together
2. Dragging to Paint
1. Setup
2. Game Loop: Handling Mouse Presses and Releases
3. Putting It All Together
1. Smiley Sprites
2. Setting Up Sprites
3. Updating Sprites
4. Bigger and Smaller Smileys
5. Putting It All Together
3. SmileyPop, Version 1.0
1. Detecting Collisions and Removing Sprites
2. Putting It All Together
4. What You Learned
18. 10. Game Programming: Coding for Fun
1. Building a Game Skeleton: Smiley Pong, Version 1.0
1. Drawing a Board and Game Pieces
2. Keeping Score
3. Showing the Score
4. Putting It All Together
2. Adding Difficulty and Ending the Game: Smiley Pong, Version 2.0
1. Game Over
2. Play Again
3. Faster and Faster
4. Putting It All Together
3. Adding More Features: SmileyPop V2.0
2. Tracking and Displaying Player Progress
3. Putting It All Together
4. What You Learned
19. A. Python Setup for Windows, Mac, and Linux
1. Python for Windows
2. Python for Mac
3. Python for Linux
20. B. Pygame Setup for Windows, Mac, and Linux
1. Pygame for Windows
2. Pygame for Mac
3. Pygame for Linux
21. C. Building Your Own Modules
1. Building the colorspiral Module