Source Code
Download
Download the source code for all the programs in one zip file here.
Or you can download the individual Python files for each program. To download, right-click these links and select "Save Target As...":
| Chapter 1 - Installing Python | (No programs in this chapter.) |
| Chapter 2 - The Interactive Shell | (No programs in this chapter.) |
| Chapter 3 - Strings | hello.py |
| Chapter 4 - Guess the Number | guess.py |
| Chapter 5 - Jokes | jokes.py |
| Chapter 6 - Dragon Realm | dragon.py |
| Chapter 7 - Flow Charts | (No programs in this chapter.) |
| Chapter 8 - Hangman | hangman.py |
| Chapter 9 - Tic Tac Toe | tictactoe.py |
| Chapter 10 - Bagels | bagels.py |
| Chapter 11 - Cartesian Coordinates | (No programs in this chapter.) |
| Chapter 12 - Sonar | sonar.py |
| Chapter 13 - Caesar Cipher | cipher.py |
| Chapter 14 - Reversi | reversi.py |
| Chapter 15 - AI Simulation | AISim1.py AISim2.py AISim3.py |
| Chapter 16 - Graphics and Animation | animation.py pygameHelloWorld.py |
| Chapter 17 - Collision Detection and Input | collisionDetection.py pygameInput.py |
| Chapter 18 - Sound and Images | spritesAndSounds.py |
| Chapter 19 - Dodger | dodger.py |
Copy and Paste
If you don't want to download the files, you can select the program you want from this dropdown menu and copy & paste the source code from the text area below.
First, click inside the text field. Then press Ctrl-A to Select All, then press Ctrl-C to Copy the selected text. Then paste the text into IDLE or your text editor.
Copyright 2008, 2009 (c) by Albert Sweigart
"Invent Your Own Computer Games with Python" 2nd Edition is free to copy and distribute under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.