Teach Your Kids To Code: A Parent-friendly Guide to Python Programming

(vip2019) #1

  • Chapter 1: Python Basics: Get to Know Your Environment Introduction: What Is Coding and Why Is It Good for Your Kids? .xxi

  • Chapter 2: Turtle Graphics: Drawing with Python

  • Chapter 3: Numbers and Variables: Python Does the Math

  • Chapter 4: Loops Are Fun (You Can Say That Again)

  • Chapter 5: Conditions (What If?)

  • Chapter 6: Random Fun and Games: Go Ahead, Take a Chance!

  • Chapter 7: Functions: There’s a Name for That

  • Chapter 8: Timers and Animation: What Would Disney Do?

  • Chapter 9: User Interaction: Get into the Game

  • Chapter 10: Game Programming: Coding for Fun

  • Appendix A: Python Setup for Windows, Mac, and Linux

  • Appendix B: Pygame Setup for Windows, Mac, and Linux

  • Appendix C: Building Your Own Modules

  • Glossary

  • Index

  • What You Learned

  • Programming Challenges

  • #1: Changing the Number of Sides

  • #2: How Many Sides?

  • #3: Rubber-Band Ball



  • numbers and Variables: Python Does the Math

  • Variables: Where We Keep Our Stuff

  • Numbers and Math in Python

  • Python Numbers

  • Python Operators

  • Doing Math in the Python Shell

  • Syntax Errors: What Did You Say?

  • Variables in the Python Shell

  • Programming with Operators: A Pizza Calculator

  • Strings: The Real Characters in Python

  • Improving Our Color Spiral with Strings

  • Lists: Keeping It All Together

  • Python Does Your Homework

  • What You Learned

  • Programming Challenges

  • #1: Circular Spirals

  • #2: Custom Name Spirals



  • loops are Fun (You Can say that again)

  • Building Your Own for Loops

  • Using a for Loop to Make a Rosette with Four Circles

  • Modifying Our for Loop to Make a Rosette with Six Circles

  • Improving Our Rosette Program with User Input

  • Game Loops and while Loops

  • The Family Spiral

  • Putting It All Together: Spiral Goes Viral

  • What You Learned

  • Programming Challenges

  • #1: Spiral Rosettes

  • #2: A Spiral of Family Spirals

  • Contents in Detail xv

  • Conditions (What if?)

  • if Statements

  • Meet the Booleans

  • Comparison Operators

  • You’re Not Old Enough!

  • else Statements

  • Polygons or Rosettes

  • Even or Odd?

  • elif Statements

  • Complex Conditions: if, and, or, not

  • Secret Messages

  • Messin’ with Strings

  • The Value of Character(s)

  • Our Encoder/Decoder Program

  • What You Learned

  • Programming Challenges

  • #1: Colorful Rosettes and Spirals

  • #2: User-Defined Keys



  • Random Fun and Games: Go ahead, take a Chance!

  • A Guessing Game

  • Colorful Random Spirals

  • Pick a Color, Any Color

  • Getting Coordinated

  • How Big Is Our Canvas?

  • Putting It All Together

  • Rock-Paper-Scissors

  • Pick a Card, Any Card

  • Stacking the Deck

  • Dealing Cards

  • Counting Cards

  • Keeping It Going

  • Putting It All Together

  • Roll the Dice: Creating a Yahtzee-Style Game

  • Setting Up the Game

  • Sorting the Dice

  • Testing the Dice

  • Putting It All Together

  • Kaleidoscope

  • What You Learned xvi Contents in Detail

  • Programming Challenges

  • #1: Random Sides and Thickness

  • #2: Realistic Mirrored Spirals

  • #3: War



  • Functions: there’s a name for that

  • Putting Things Together with Functions

  • Defining random_spiral()

  • Calling random_spiral()

  • Parameters: Feeding Your Function

  • Smileys at Random Locations

  • Putting It All Together

  • Return: It’s What You Give Back That Counts

  • Returning a Value from a Function

  • Using Return Values in a Program

  • A Touch of Interaction

  • Handling Events: TurtleDraw

  • Listening for Keyboard Events: ArrowDraw

  • Handling Events with Parameters: ClickSpiral

  • Taking It One Step Further: ClickandSmile

  • ClickKaleidoscope

  • The draw_kaleido() Function

  • The draw_spiral() Function

  • Putting It All Together

  • What You Learned

  • Programming Challenges

  • #1: Mirrored Smileys

  • #2: More Ping-Pong Calculations

  • #3: A Better Drawing Program



  • timers and animation: What Would Disney Do?

  • Getting All GUI with Pygame

  • Drawing a Dot with Pygame

  • What’s New in Pygame

  • The Parts of a Game

  • Timing It Just Right: Move and Bounce

  • Moving a Smiley

  • Animating a Smiley with the Clock Class

  • Bouncing a Smiley Off a Wall

  • Bouncing a Smiley Off Four Walls

  • What You Learned Contents in Detail xvii

  • Programming Challenges

  • #1: A Color-Changing Dot

  • #2: 100 Random Dots

  • #3: Raining Dots



  • User interaction: Get into the Game

  • Adding Interaction: Click and Drag

  • Clicking for Dots

  • Dragging to Paint

  • Advanced Interaction: Smiley Explosion

  • Smiley Sprites

  • Setting Up Sprites

  • Updating Sprites

  • Bigger and Smaller Smileys

  • Putting It All Together

  • SmileyPop, Version 1 .0

  • Detecting Collisions and Removing Sprites

  • Putting It All Together

  • What You Learned

  • Programming Challenges

  • #1: Randomly Colored Dots

  • #2: Painting in Colors

  • #3: Throwing Smileys



  • Game Programming: Coding for Fun

  • Smiley Pong, Version Building a Game Skeleton:

  • Drawing a Board and Game Pieces

  • Keeping Score

  • Showing the Score

  • Putting It All Together

  • Adding Difficulty and Ending the Game: Smiley Pong, Version

  • Game Over

  • Play Again

  • Faster and Faster

  • Putting It All Together

  • Adding More Features: SmileyPop v2

  • Adding Sound with Pygame

  • Tracking and Displaying Player Progress

  • Putting It All Together

  • What You Learned xviii Contents in Detail

  • Programming Challenges

  • #1: Sound Effects

  • #2: Hits and Misses

  • #3: Clear the Bubbles

  • Python setup for Windows, Mac, and linux a

  • Python for Windows

  • Download the Installer

  • Run the Installer

  • Try Out Python

  • Python for Mac

  • Download the Installer

  • Run the Installer

  • Try Out Python

  • Python for Linux

  • Pygame setup for Windows, Mac, and linux B

  • Pygame for Windows

  • Pygame for Mac

  • Python 2 .7 and Pygame 1 9 .2

  • Pygame for Linux

  • Pygame for Python

  • Building Your own Modules C

  • Building the colorspiral Module

  • Using the colorspiral Module

  • Reusing the colorspiral Module

  • Additional Resources

  • Glossary

  • index

Free download pdf