You are previewing Teach Your Kids to Code.
O'Reilly logo
Teach Your Kids to Code

Book Description

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

Table of Contents

  1. Teach Your Kids to Code: A Parent-Friendly Guide to Python Programming
  2. Dedication
  3. Advance Praise for Teach Your Kids to Code
  4. About the Author
  5. About the Illustrator
  6. About the Technical Reviewer
  7. Acknowledgments
  8. Introduction: What Is Coding and Why Is It Good for Your Kids?
    1. Why Should Kids Learn to Code?
      1. Coding Is Fun
      2. Coding Is a Valuable Job Skill
    2. Where Can Kids Learn to Code?
    3. How to Use This Book
      1. Explore!
      2. Do It Together!
      3. Online Resources
    4. Coding = Solving Problems
  9. 1. Python Basics: Get to Know Your Environment
    1. Getting Started with Python
      1. 1. Download Python
      2. 2. Install Python
      3. 3. Test Python with a Program
    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
      1. SquareSpiral1.py
      2. How It Works
      3. What Happens
    2. Turtle on a Roll
      1. SquareSpiral2.py
    3. Turtle Roundup
      1. CircleSpiral1.py
    4. Adding a Touch of Color
      1. SquareSpiral3.py
      2. A Four-Color Spiral
        1. ColorSquareSpiral.py
      3. Changing Background Colors
        1. ColorCircleSpiral.py
    5. One Variable to Rule Them All
      1. ColorSpiral.py
    6. What You Learned
  11. 3. Numbers and Variables: Python Does the Math
    1. Variables: Where We Keep Our Stuff
      1. ThankYou.py
    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
        1. AtlantaPizza.py
    3. Strings: The Real Characters in Python
      1. SayMyName.py
    4. Improving Our Color Spiral With Strings
      1. SpiralMyName.py
    5. Lists: Keeping It All Together
      1. ColorSpiralInput.py
    6. Python Does Your Homework
      1. MathHomework.py
    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
        1. Rosette4.py
      2. Modifying Our for Loop to Make a Rosette with Six Circles
        1. Rosette6.py
    3. Improving Our Rosette Program with User Input
      1. RosetteGoneWild.py
    4. Game Loops and while Loops
      1. SayOurNames.py
    5. The Family Spiral
      1. SpiralFamily.py
    6. Putting It All Together: Spiral Goes Viral
      1. ViralSpiral.py
    7. What You Learned
  13. 5. Conditions (What If?)
    1. If Statements
      1. IfSpiral.py
    2. Meet the Booleans
      1. Comparison Operators
      2. You’re Not Old Enough!
        1. OldEnough.py
    3. Else Statements
      1. OldEnoughOrElse.py
      2. Polygons or Rosettes
        1. PolygonOrRosette.py
      3. Even or Odd?
        1. RosettesAndPolygons.py
    4. Elif Statements
      1. WhatsMyGrade.py
    5. Complex Conditions: If, and, or, not
      1. WhatToWear.py
    6. Secret Messages
      1. Messin’ with Strings
      2. The Value of Character(s)
      3. Our Encoder/Decoder Program
        1. EncoderDecoder.py
    7. What You Learned
  14. 6. Random Fun and Games: Go Ahead, Take a Chance!
    1. A Guessing Game
      1. GuessingGame.py
    2. Colorful Random Spirals
      1. Pick a Color, Any Color
      2. Getting Coordinated
        1. Cartesian Coordinates
        2. Setting a Random Turtle Position
      3. How Big Is Our Canvas?
      4. Putting It All Together
        1. RandomSpirals.py
    3. Rock-Paper-Scissors
      1. RockPaperScissors.py
    4. Pick a Card, Any Card
      1. Stacking the Deck
      2. Dealing Cards
      3. Counting Cards
        1. Finding an Item in a List
        2. Which Card is Higher?
      4. Keeping It Going
      5. Putting It All Together
        1. HighCard.py
    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
        1. FiveDice.py
    6. Kaleidoscope
      1. Kaleidoscope.py
    7. What You Learned
  15. 7. Functions: There’s a Name for That
    1. Putting Things Together with Functions
      1. Defining Random_Spiral()
      2. Calling Random_Spiral()
      3. RandomSpiralsFunction.py
    2. Parameters: Feeding Your Function
      1. Smileys at Random Locations
        1. Drawing a head
        2. Drawing eyes
        3. Drawing a mouth
        4. Defining and Calling Draw_Smiley()
      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
        1. PingPongCalculator.py
    4. A Touch of Interaction
      1. Handling Events: TurtleDraw
        1. TurtleDraw.py
        2. TurtleDrawMax.py
      2. Listening for Keyboard Events: ArrowDraw
        1. ArrowDraw.py
      3. Handling Events with Parameters: Clickspiral
        1. ClickSpiral.py
      4. Taking It One Step Further: Clickandsmile
        1. ClickAndSmile.py
    5. ClickKaleidoscope
      1. The Draw_Kaleido() Function
      2. The Draw_Spiral() Function
      3. Putting It All Together
        1. ClickKaleidoscope.py
    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
        1. ShowDot.py
      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
          1. ShowPic.py
    2. Timing It Just Right: Move and Bounce
      1. Moving a Smiley
      2. Animating a Smiley with the Clock Class
        1. SmileyMove.py
      3. Bouncing a Smiley Off a Wall
        1. Hitting the Wall
        2. Changing Direction
        3. Putting It All Together
          1. SmileyBounce1.py
      4. Bouncing a Smiley Off Four Walls
        1. Horizontal and Vertical Speed
        2. Hitting Four Walls
        3. Putting It All Together
          1. SmileyBounce2.py
    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
          1. ClickDots.py
      2. Dragging to Paint
        1. Setup
        2. Game Loop: Handling Mouse Presses and Releases
        3. Putting It All Together
          1. DragDots.py
    2. Advanced Interaction: Smiley Explosion
      1. Smiley Sprites
        1. More on Classes and Objects
        2. Using classes to Build our app
      2. Setting Up Sprites
      3. Updating Sprites
      4. Bigger and Smaller Smileys
      5. Putting It All Together
        1. SmileyExplosion.py
    3. SmileyPop, Version 1.0
      1. Detecting Collisions and Removing Sprites
      2. Putting It All Together
        1. SmileyPop.py
    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
        1. Subtracting a Life
        2. Hitting the Ball with the Paddle
        3. Adding a Point
      3. Showing the Score
      4. Putting It All Together
        1. SmileyPong1.py
    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
        1. SmileyPong2.py
    3. Adding More Features: SmileyPop V2.0
      1. Adding Sound with Pygame
      2. Tracking and Displaying Player Progress
        1. Smileys Created and Popped
        2. Percentage of Smileys Popped
      3. Putting It All Together
        1. SmileyPop2.py
    4. What You Learned
  19. A. Python Setup for Windows, Mac, and Linux
    1. Python for Windows
      1. Download the Installer
      2. Run the Installer
      3. Try Out Python
    2. Python for Mac
      1. Download the Installer
      2. Run the Installer
      3. Try Out Python
    3. Python for Linux
  20. B. Pygame Setup for Windows, Mac, and Linux
    1. Pygame for Windows
    2. Pygame for Mac
      1. Python 2.7 and Pygame 1.9.2
    3. Pygame for Linux
      1. Pygame for Python 2
  21. C. Building Your Own Modules
    1. Building the colorspiral Module
      1. colorspiral.py
      2. Using The Colorspiral Module
      3. MultiSpiral.py
      4. Reusing the Colorspiral Module
      5. SuperSpiral.py
    2. Additional Resources
  22. D. Glossary
  23. E. Updates
  24. Index
  25. Copyright