0%

Book Description

Full of fun examples and color illustrations, Python For Kids is a playful introduction to Python that will help any beginner get started with programming.

Table of Contents

  1. Python for Kids
  2. About the Author
  3. About the Illustrator
  4. About the technical Reviewers
  5. Acknowledgments
  6. Introduction
    1. Why Python?
    2. How to Learn to Code
    3. Who Should Read This Book
    4. What’s in This Book
    5. The Companion Website
    6. Have Fun!
  7. I. Learning to Program
    1. 1. Not All Snakes Slither
      1. A Few Words About Language
      2. Installing Python
        1. Installing Python on Windows 7
        2. Installing Python on Mac OS X
        3. Installing Python on Ubuntu
      3. Once You’ve Installed Python
      4. Saving Your Python Programs
      5. What You Learned
    2. 2. Calculations and Variables
      1. Calculating with Python
        1. Python Operators
        2. The Order of Operations
      2. Variables Are Like Labels
      3. Using Variables
      4. What You Learned
    3. 3. Strings, Lists, Tuples, and Maps
      1. Strings
        1. Creating Strings
        2. Handling Problems with Strings
        3. Embedding Values in Strings
        4. Multiplying Strings
      2. Lists Are More Powerful Than Strings
        1. Adding Items to a List
        2. Removing Items from a List
        3. List Arithmetic
      3. Tuples
      4. Python Maps Won’t Help You Find Your Way
      5. What You Learned
      6. Programming Puzzles
        1. #1: Favorites
        2. #2: Counting Combatants
        3. #3: Greetings!
    4. 4. Drawing with Turtles
      1. Using Python’s turtle Module
        1. Creating a Canvas
        2. Moving the Turtle
      2. What You Learned
      3. Programming Puzzles
        1. #1: A Rectangle
        2. #2: A Triangle
        3. #3: A Box Without Corners
    5. 5. Asking Questions with if and else
      1. if Statements
        1. A Block Is a Group of Programming Statements
        2. Conditions Help Us Compare Things
      2. if-then-else Statements
      3. if and elif Statements
      4. Combining Conditions
      5. Variables with No Value—None
      6. The Difference Between Strings and Numbers
      7. What You Learned
      8. Programming Puzzles
        1. #1: Are You Rich?
        2. #2: Twinkies!
        3. #3: Just the Right Number
        4. #4: I Can Fight Those Ninjas
    6. 6. Going Loopy
      1. Using for Loops
      2. While We’re Talking About Looping . . .
      3. What You Learned
      4. Programming Puzzles
        1. #1: The Hello Loop
        2. #2: Even Numbers
        3. #3: My Five Favorite Ingredients
        4. #4: Your Weight on the Moon
    7. 7. Recycling Your Code with Functions and Modules
      1. Using Functions
        1. Parts of a Function
        2. Variables and Scope
      2. Using Modules
      3. What You Learned
      4. Programming Puzzles
        1. #1: Basic Moon Weight Function
        2. #2: Moon Weight Function and Years
        3. #3: Moon Weight Program
    8. 8. How to Use Classes and Objects
      1. Breaking Things into Classes
        1. Children and Parents
        2. Adding Objects to Classes
        3. Defining Functions of Classes
        4. Adding Class Characteristics as Functions
        5. Why Use Classes and Objects?
        6. Objects and Classes in Pictures
      2. Other Useful Features of Objects and Classes
        1. Inherited Functions
        2. Functions Calling Other Functions
      3. Initializing an Object
      4. What You Learned
      5. Programming Puzzles
        1. #1: The Giraffe Shuffle
        2. #2: Turtle Pitchfork
    9. 9. Python’s Built-in Functions
      1. Using Built-in Functions
        1. The abs Function
        2. The bool Function
        3. The dir Function
        4. The eval Function
        5. The exec Function
        6. The float Function
        7. The int Function
        8. The len Function
        9. The max and min Functions
        10. The range Function
        11. The sum Function
      2. Working with Files
        1. Creating a Test File
          1. Creating a New File in Windows
          2. Creating a New File in Mac OS X
          3. Creating a New File in Ubuntu
        2. Opening a File in Python
          1. Opening a Windows File
          2. Opening a Mac OS X File
          3. Opening an Ubuntu File
        3. Writing to Files
      3. What You Learned
      4. Programming Puzzles
        1. #1: Mystery Code
        2. #2: A Hidden Message
        3. #3: Copying a File
    10. 10. Useful Python Modules
      1. Making Copies with the copy Module
      2. Keeping Track of Keywords with the keyword Module
      3. Getting Random Numbers with the random Module
        1. Using randint to Pick a Random Number
        2. Using choice to Pick a Random Item from a List
        3. Using shuffle to Shuffle a List
      4. Controlling the Shell with the sys Module
        1. Exiting the Shell with the exit function
        2. Reading with the stdin Object
        3. Writing with the stdout Object
        4. Which Version of Python Am I Using?
      5. Doing Time with the time Module
        1. Converting a Date with asctime
        2. Getting the Date and Time with localtime
        3. Taking Some Time Off with sleep
      6. Using the pickle Module to Save Information
      7. What You Learned
      8. Programming Puzzles
        1. #1: Copied Cars
        2. #2: Pickled Favorites
    11. 11. More Turtle Graphics
      1. Starting with the Basic Square
      2. Drawing Stars
      3. Drawing a Car
      4. Coloring Things In
        1. A Function to Draw a Filled Circle
        2. Creating Pure Black and White
      5. A Square-Drawing Function
      6. Drawing Filled Squares
      7. Drawing Filled Stars
      8. What You Learned
      9. Programming Puzzles
        1. #1: Drawing an Octagon
        2. #2: Drawing a Filled Octagon
        3. #3: Another Star-Drawing Function
    12. 12. Using tkinter for Better Graphics
      1. Creating a Clickable Button
      2. Using Named Parameters
      3. Creating a Canvas for Drawing
      4. Drawing Lines
      5. Drawing Boxes
        1. Drawing a Lot of Rectangles
        2. Setting the Color
      6. Drawing Arcs
      7. Drawing Polygons
      8. Displaying Text
      9. Displaying Images
      10. Creating Basic Animation
      11. Making an Object React to Something
      12. More Ways to Use the Identifier
      13. What You Learned
      14. Programming Puzzles
        1. #1: Fill the Screen with Triangles
        2. #2: The Moving Triangle
        3. #3: The Moving Photo
  8. II. Bounce!
    1. 13. Beginning Your First Game: Bounce!
      1. Whack the Bouncing Ball
      2. Creating the Game Canvas
      3. Creating the Ball Class
      4. Adding Some Action
        1. Making the Ball Move
        2. Making the Ball Bounce
        3. Changing the Ball’s Starting Direction
      5. What You Learned
    2. 14. Finishing Your First Game: Bounce!
      1. Adding the Paddle
        1. Making the Paddle Move
        2. Finding Out When the Ball Hits the Paddle
      2. Adding an Element of Chance
      3. What You Learned
      4. Programming Puzzles
        1. #1: Delay the Game Start
        2. #2: A Proper “Game Over”
        3. #3: Accelerate the Ball
        4. #4: Record the Player’s Score
  9. III. Mr. Stick Man Races for the Exit
    1. 15. Creating Graphics for the Mr. Stick Man Game
      1. Mr. Stick Man Game Plan
      2. Getting GIMP
      3. Creating the Game Elements
        1. Preparing a Transparent Image
        2. Drawing Mr. Stick Man
          1. Mr. Stick Man Running to the Right
          2. Mr. Stick Man Running to the Left
        3. Drawing the Platforms
        4. Drawing the Door
        5. Drawing the Background
        6. Transparency
      4. What You Learned
    2. 16. Developing the Mr. Stick Man Game
      1. Creating the Game Class
        1. Setting the Window Title and Creating the Canvas
        2. Finishing the _init_ Function
        3. Creating the mainloop Function
      2. Creating the Coords Class
      3. Checking for Collisions
        1. Sprites Colliding Horizontally
        2. Sprites Colliding Vertically
        3. Putting It All Together: Our Final Collision-Detection Code
          1. The collided_left Function
          2. The collided_right Function
          3. The collided_top Function
          4. The collided_bottom Function
      4. Creating the Sprite Class
      5. Adding the Platforms
        1. Adding a Platform Object
        2. Adding a Bunch of Platforms
      6. What You Learned
      7. Programming Puzzles
        1. #1: Checkerboard
        2. #2: Two-Image Checkerboard
        3. #3: Bookshelf and Lamp
    3. 17. Creating Mr. Stick Man
      1. Initializing the Stick Figure
        1. Loading the Stick Figure Images
        2. Setting Up Variables
        3. Binding to Keys
      2. Turning the Stick Figure Left and Right
      3. Making the Stick Figure Jump
      4. What We Have So Far
      5. What You Learned
    4. 18. Completing the Mr. Stick Man Game
      1. Animating the Stick Figure
        1. Creating the Animate Function
          1. Checking for Movement
          2. Changing the Image
        2. Getting the Stick Figure’s Position
        3. Making the Stick Figure Move
          1. Starting the move Function
          2. Has the stick Figure Hit the Bottom or Top of the Canvas?
          3. Has the Stick Figure Hit the Side of the Canvas?
          4. Colliding with Other Sprites
          5. Colliding at the Bottom
          6. Checking Left and Right
      2. Testing Our Stick Figure Sprite
      3. The Door!
        1. Creating the DoorSprite Class
        2. Detecting the Door
        3. Adding the Door Object
      4. The Final Game
      5. What You Learned
      6. Programming Puzzles
        1. #1: “You Win!”
        2. #2: Animating the Door
        3. #3: Moving Platforms
  10. A. Where to Go from Here
    1. Games and Graphics Programming
      1. PyGame
    2. Programming Languages
      1. Java
      2. C/C++
      3. C#
      4. PHP
      5. Objective-C
      6. Perl
      7. Ruby
      8. JavaScript
    3. Final Words
  11. B. Python Keywords
    1. and
      1. and
      2. as
      3. assert
      4. break
      5. class
      6. continue
      7. def
      8. del
      9. elif
      10. else
      11. except
      12. finally
      13. for
      14. from
      15. global
      16. if
      17. import
      18. in
      19. is
      20. lambda
      21. not
      22. or
      23. pass
      24. raise
      25. return
      26. try
      27. while
      28. with
      29. yield
  12. Glossary
  13. Index
  14. About the Author
  15. Updates
  16. Copyright
3.139.90.131