Jason R Briggs

Python for Kids

Code Snippets from the Book

Gorilla Here's some of the longer code samples used in "Python for Kids". If you're having trouble getting any of the code in the book to work, why not download it from here and compare with what you've typed - it might help you figure out where you've gone wrong. If you're really struggling... you can always get in contact.

(Update: the stick figure zip file link was broken - it's now been fixed)

Chapter 2

Magic coins example. magic_coins1.py

Chapter 3

Favourite sports. favourite_sports.py
Furniture placeholder. furniture_placeholder.py
A list of lists. list_of_lists.py
A letter from Malcolm Dithering dithering_letter.py
Escaping quotes quote_escaping.py
The Wizard List wizard_list.py

Chapter 4

The turtle draws a square. turtle1.py
The turtle draws two parallel lines. turtle2.py

Chapter 5

If statements if_statements.py
Conditions in if-statements. conditions.py
Else-if (elif) statements. elif_statements.py
Strings and numbers. strings_and_numbers.py

Chapter 6

Five Hellos. five_hellos.py
Huge hairy pants (example 1). huge_hairy_pants1.py
Huge hairy pants (example 2). huge_hairy_pants2.py
Magic coins (example 2). magic_coins2.py
A while-loop with multiple conditions. while_loop_multiple_conditions.py
Looping through the wizard list. wizard_list_loop.py

Chapter 7

A function to calculate your savings. savings.py
Building a spaceship. spaceship_building.py
Test function (example 1). test_function1.py
Test function (example 2). test_function2.py
Your age function. your_age.py

Chapter 8

Giraffes (example 1). giraffes1.py
Giraffes (example 2). giraffes2.py
Three turtles. three_turtles.py

Chapter 9

Using the abs (absolute) function. abs_function.py
Using the exec (execute) function. exec_function.py
Using the len (length) function. len_function.py
Using the max and min functions. max_and_min.py
Using the range function. range_function.py
Using the sum function. range_function.py
Opening a file. opening_a_file.py
Writing to a file. writing_to_a_file.py

Chapter 10

Copying objects (example 1). copying_objects1.py
Copying objects (example 2). copying_objects2.py
Guess a random number. guess_a_number.py
Random desserts. random_desserts.py
Using the time module. timing_lots_of_numbers.py
Using pickle to save information. pickle_saving.py
Using pickle to load information. pickle_loading.py

Chapter 11

Drawing an eight point star. eight_point_star.py
Drawing a many point star. many_point_star.py
Drawing a spiral star. spiral_star.py
Drawing a nine point star. nine_point_star.py
Drawing a car. car.py
Drawing a yellow circle. yellow_circle.py
Drawing a filled green circle. green_circle.py
Drawing a dark-green circle. dark_green_circle.py
Drawing squares using a function. square_function.py
Drawing filled and unfilled squares. filled_squares.py
Drawing stars using a function. star_function.py

Chapter 12

Clickable button (example 1). clickable_button1.py
Clickable button (example 2). clickable_button2.py
Drawing a diagonal line. diagonal_line.py
Drawing a square. square.py
Drawing a horizontal rectangle. horizonal_rectangle.py
Drawing a vertical rectangle. vertical_rectangle.py
Drawing random rectangles. random_rectangles.py
Drawing coloured rectangles. coloured_rectangles.py
Using the color chooser. rectangle_colorchooser.py
Drawing arcs. drawing_arcs.py
Drawing polygons. drawing_polygons.py
Drawing text. drawing_text.py
Drawing images. drawing_images.py
Basic animation (example 1). basic_animation1.py
Basic animation (example 2). basic_animation2.py
Using events (example 1). using_events1.py
Using events (example 2). using_events1.py
Using the move function. using_move.py
Using the itemconfig function. using_itemconfig.py

Chapter 13

Bounce (example 1) - this one doesn't do anything when it's run. bounce1.py
Bounce (example 2) - stationary ball. bounce2.py
Bounce (example 3) - ball moving upwards. bounce3.py
Bounce (example 4) - ball moving up and down. bounce4.py
Bounce (example 5) - ball moving around the screen. bounce5.py

Chapter 14

Bounce (example 6) - adding the paddle. bounce6.py
Bounce (example 7) - moving paddle. bounce7.py
Bounce (example 8) - bouncing the ball when it hits the paddle. bounce8.py
Bounce (example 9) - ending the game when the ball hits the floor. bounce9.py

Chapter 15

Transparent Image - 27 by 30 pixels. transparent-image.gif
6 Stick Figure Images - left and right. stickfigure.zip
3 Platform images. platform.zip
2 Door images. door.zip
Background image. background.gif

Chapter 16

Stickman Game, version 1 - displaying the background. stickmangame1.py
Stickman Game, version 2 - adding the within functions. stickmangame2.py
Stickman Game, version 3 - adding the platform. stickmangame3.py
Stickman Game, version 4 - adding lots of platforms. stickmangame4.py

Chapter 17

Stick figure sprite class. stickfiguresprite.py
Stickman Game, version 5 - adding the stick figure. stickmangame5.py

Chapter 18

Stickman Game, version 6 - animating the stick figure. stickmangame6.py
Stickman Game, version 6 - adding the door sprite. stickmangame7.py


Pygame2 example. pygame-example.py
Hello World Java example. HelloWorld.java
Hello World C example. helloworld.c
Hello World C++ example. helloworld.cpp
Hello World C# example. helloworld.cs
Hello World PHP example. helloworld.php
Hello World Objective-C example. helloworld.m
Hello World Perl example. helloworld.pl
Hello World Ruby example. helloworld.rb
Hello World Javascript example. helloworld.js
Hello World Javascript Browser example. helloworld-js.html