Hello world! : computer programming for kids and other beginners

cover image

Where to find it

Information & Library Science Library

Call Number
QA76.73.P98 S26 2009
Status
Available

Authors, etc.

Names:

Summary

"Computer programming is a powerful tool for children to 'learn learning,' that is, to learn the skills of thinking and problem-solving...Children who engage in programming transfer that kind of learning to other things."--Nicholas Negroponte, the man behind the One Laptop Per Child project that hopes to put a computer in the hands of every child on earth, January 2008

Your computer won't respond when you yell at it. Why not learn to talk to your computer in its own language? Whether you want to write games, start a business, or you're just curious, learning to program is a great place to start. Plus, programming is fun!

Hello World! provides a gentle but thorough introduction to the world of computer programming. It's written in language a 12-year-old can follow, but anyone who wants to learn how to program a computer can use it. Even adults. Written by Warren Sande and his son, Carter, and reviewed by professional educators, this book is kid-tested and parent-approved.

You don't need to know anything about programming to use the book. But you should know the basics of using a computer--e-mail, surfing the web, listening to music, and so forth. If you can start a program and save a file, you should have no trouble using this book.

Purchase of the print book comes with an offer of a free PDF, ePub, and Kindle eBook from Manning. Also available is all code from the book.

Contents

  • Preface p. xiii
  • Acknowledgments p. xix
  • About this book p. xxi
  • 1 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
  • 2 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
  • 3 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
  • 4 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
  • 5 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
  • 6 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
  • 7 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
  • 8 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
  • 9 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
  • 10 Game Time p. 94
  • Skier p. 94
  • 11 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
  • 12 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
  • 13 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
  • 14 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
  • 15 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
  • 16 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
  • 17 Sprites and Collision Detection p. 202
  • Sprites p. 202
  • Bump! Collision detection p. 208
  • Counting time p. 212
  • 18 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
  • 19 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
  • 20 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
  • 21 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
  • 22 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
  • 23 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
  • 24 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
  • 25 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
  • Appendix A Variable Naming Rules p. 363
  • Answers to Self-Test Questions p. 365
  • Chapter 1 Getting Started p. 365
  • Chapter 2 Remember This-Memory and Variables p. 366
  • Chapter 3 Basic Math p. 367
  • Chapter 4 Types of Data p. 368
  • Chapter 5 Input p. 369
  • Chapter 6 GUIs-Graphical User Interfaces p. 371
  • Chapter 7 Decisions, Decisions p. 372
  • Chapter 8 Loop the Loop p. 374
  • Chapter 9 Just for You-Comments p. 375
  • Chapter 10 Game Time p. 376
  • Chapter 11 Nested and Variable Loops p. 376
  • Chapter 12 Collecting Things Together-Lists p. 377
  • Chapter 13 Functions p. 379
  • Chapter 14 Objects p. 380
  • Chapter 15 Modules p. 382
  • Chapter 16 Graphics p. 383
  • Chapter 17 Sprites and Collision Detection p. 385
  • Chapter 18 A New Kind of Input-Events p. 385
  • Chapter 19 Sound p. 386
  • Chapter 20 More GUIs p. 386
  • Chapter 21 Print Formatting and Strings p. 387
  • Chapter 22 File Input and Output p. 388
  • Chapter 23 Take a Chance-Randomness p. 390
  • Chapter 24 Computer Simulations p. 391
  • Index p. 393

Other details