Warren Sande is an Electronic Systems Engineer who uses Python (and other languages) in his work, and also uses it to help teach his son about computers and programming. He holds a degree in Electronic Systems Engineering from the University of Regina, Saskatchewan as well as a Diploma in Communication Arts, specializing in Broadcasting, from the Southern Alberta Institute of Technology. He has taught introductory software courses to computer novices.
Preface | p. xiii |
Acknowledgments | p. xix |
About this book | p. xxi |
Getting Started | p. 1 |
Installing Python | p. 1 |
Starting Python with IDLE | p. 2 |
Instructions, please | p. 3 |
Interacting with Python | p. 5 |
Time to program | p. 7 |
Running your first program | p. 8 |
If something goes wrong | p. 9 |
Your second program | p. 11 |
Remember This-Memory and Variables | p. 14 |
Input, processing, output | p. 14 |
Names | p. 16 |
What's in a name? | p. 20 |
Numbers and strings | p. 21 |
How "variable" are they? | p. 22 |
The new me | p. 23 |
Basic Math | p. 26 |
The four basic operations | p. 27 |
Operators | p. 28 |
Order of operations | p. 29 |
Two more operators | p. 30 |
Really big and really small | p. 33 |
Types of Data | p. 38 |
Changing types | p. 38 |
Getting more information: type() | p. 41 |
Type-conversion errors | p. 42 |
Using type conversions | p. 42 |
Input | p. 44 |
raw_input () | p. 45 |
The print command and the comma | p. 45 |
Inputting numbers | p. 47 |
Input from the Web | p. 49 |
GUIs-Graphical User Interfaces | p. 52 |
What's a GUI? | p. 52 |
Our first GUI | p. 53 |
GUI input | p. 54 |
Pick your flavor | p. 55 |
The number-guessing game ... again | p. 59 |
Other GUI pieces | p. 60 |
Decisions, Decisions | p. 62 |
Testing, testing | p. 62 |
Indenting | p. 65 |
Am I seeing double? | p. 65 |
Other kinds of tests | p. 66 |
What happens if the test is false? | p. 67 |
Testing for more than one condition | p. 69 |
Using "and" | p. 69 |
Using "or" | p. 70 |
Using "not" | p. 70 |
Loop the Loop | p. 74 |
Counting loops | p. 75 |
Using a counting loop | p. 77 |
A shortcut-range () | p. 78 |
A matter of style-loop variable names | p. 80 |
Counting by steps | p. 82 |
Counting without numbers | p. 84 |
While we're on the subject ... | p. 84 |
Bailing out of a loop-break and continue | p. 85 |
Just for You-Comments | p. 89 |
Adding comments | p. 89 |
Single-line comments | p. 90 |
End-of-line comments | p. 90 |
Multiline comments | p. 90 |
Commenting style | p. 91 |
Commenting out | p. 92 |
Game Time | p. 94 |
Skier | p. 94 |
Nested and Variable Loops | p. 99 |
Nested loops | p. 99 |
Variable loops | p. 101 |
Variable nested loops | p. 102 |
Even more variable nested loops | p. 103 |
Using nested loops | p. 105 |
Collecting Things Together-Lists | p. 112 |
What's a list? | p. 112 |
Creating a list | p. 113 |
Adding things to a list | p. 113 |
What's the dot? | p. 114 |
Lists can hold anything | p. 114 |
Getting items from a list | p. 115 |
"Slicing" a list | p. 116 |
Modifying items | p. 118 |
Other ways of adding to a list | p. 118 |
Deleting from a list | p. 120 |
Searching a list | p. 121 |
Looping through a list | p. 122 |
Sorting lists | p. 123 |
Mutable and immutable | p. 126 |
Lists of lists: tables of data | p. 126 |
Functions | p. 131 |
Functions-the building blocks | p. 131 |
Calling a function | p. 133 |
Passing arguments to a function | p. 134 |
Functions with more than one argument | p. 137 |
Functions that return a value | p. 139 |
Variable scope | p. 140 |
Forcing a global | p. 143 |
A bit of advice on naming variables | p. 144 |
Objects | p. 146 |
Objects in the real world | p. 147 |
Objects in Python | p. 147 |
Object = attributes + methods | p. 148 |
What's the dot? | p. 149 |
Creating objects | p. 149 |
An example class-HotDog | p. 154 |
Hiding the data | p. 159 |
Polymorphism and inheritance | p. 159 |
Thinking ahead | p. 162 |
Modules | p. 164 |
What's a module? | p. 164 |
Why use modules? | p. 164 |
Buckets of blocks | p. 165 |
How do we create modules? | p. 165 |
How do we use modules? | p. 166 |
Namespaces | p. 167 |
Standard modules | p. 170 |
Graphics | p. 174 |
Getting some help-Pygame | p. 174 |
A Pygame window | p. 175 |
Drawing in the window | p. 178 |
Individual pixels | p. 186 |
Images | p. 190 |
Let's get moving! | p. 192 |
Animation | p. 193 |
Smoother animation | p. 194 |
Bouncing the ball | p. 196 |
Wrapping the ball | p. 198 |
Sprites and Collision Detection | p. 202 |
Sprites | p. 202 |
Bump! Collision detection | p. 208 |
Counting time | p. 212 |
A New Kind of Input-Events | p. 217 |
Events | p. 217 |
Keyboard events | p. 219 |
Mouse events | p. 223 |
Timer events | p. 225 |
Time for another game-PyPong | p. 227 |
Sound | p. 239 |
More help from Pygame-mixer | p. 239 |
Making sounds versus playing sounds | p. 240 |
Playing sounds | p. 240 |
Controlling volume | p. 243 |
Repeating music | p. 245 |
Adding sounds to PyPong | p. 245 |
More wacky sounds | p. 246 |
Adding music to PyPong | p. 250 |
More GUIs | p. 254 |
Working with PythonCard | p. 254 |
Components | p. 255 |
Making our GUI do something | p. 258 |
The return of event handlers | p. 259 |
Moving the button | p. 260 |
More useful GUIs | p. 260 |
TempGUI | p. 261 |
What's on the menu? | p. 266 |
Print Formatting and Strings | p. 273 |
New lines | p. 274 |
Horizontal spacing-tabs | p. 275 |
Inserting variables in strings | p. 277 |
Number formatting | p. 278 |
Strings 'n' things | p. 282 |
File Input and Output | p. 290 |
What's a file? | p. 291 |
Filenames | p. 291 |
File locations | p. 292 |
Opening a file | p. 296 |
Reading a file | p. 297 |
Text files and binary files | p. 299 |
Writing to a file | p. 300 |
Saving your stuff in files: pickle | p. 303 |
Game time again-Hangman | p. 305 |
Take a Chance-Randomness | p. 313 |
What's randomness? | p. 313 |
Rolling the dice | p. 314 |
Creating a deck of cards | p. 319 |
Crazy Eights | p. 323 |
Computer Simulations | p. 336 |
Modeling the real world | p. 336 |
Lunar Lander | p. 337 |
Keeping time | p. 342 |
Time objects | p. 343 |
Saving time to a file | p. 347 |
Virtual Pet | p. 349 |
What's Next? | p. 358 |
General programming | p. 358 |
Python | p. 359 |
Game programming and Pygame | p. 359 |
Other Python stuff | p. 360 |
Look around | p. 362 |
Variable Naming Rules | p. 363 |
Answers to Self-Test Questions | p. 365 |
Getting Started | p. 365 |
Remember This-Memory and Variables | p. 366 |
Basic Math | p. 367 |
Types of Data | p. 368 |
Input | p. 369 |
GUIs-Graphical User Interfaces | p. 371 |
Decisions, Decisions | p. 372 |
Loop the Loop | p. 374 |
Just for You-Comments | p. 375 |
Game Time | p. 376 |
Nested and Variable Loops | p. 376 |
Collecting Things Together-Lists | p. 377 |
Functions | p. 379 |
Objects | p. 380 |
Modules | p. 382 |
Graphics | p. 383 |
Sprites and Collision Detection | p. 385 |
A New Kind of Input-Events | p. 385 |
Sound | p. 386 |
More GUIs | p. 386 |
Print Formatting and Strings | p. 387 |
File Input and Output | p. 388 |
Take a Chance-Randomness | p. 390 |
Computer Simulations | p. 391 |
Index | p. 393 |
Table of Contents provided by Ingram. All Rights Reserved. |
The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.
The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.