Hello World!: Computer Programming for Kids and Other Beginners

Hello World!: Computer Programming for Kids and Other Beginners

by Warren Sande, Carter Sande

Paperback(Second Edition)

$39.99 View All Available Formats & Editions
Choose Expedited Shipping at checkout for guaranteed delivery by Wednesday, April 24

Product Details

ISBN-13: 9781617290923
Publisher: Manning Publications Company
Publication date: 12/28/2013
Edition description: Second Edition
Pages: 435
Sales rank: 471,214
Product dimensions: 7.30(w) x 9.20(h) x 1.30(d)
Age Range: 10 - 16 Years

About the Author

Warren Sande is an Electronic Systems Engineer who uses Python as his favorite "do anything" scripting language at work, and also uses it to help teach people 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 from the Southern Alberta Institute of Technology.

Carter Sande is a high school student who is passionate about technology. When he's not fixing his school's network and helping his classmates recover lost homework, he likes to ride his bike and write retro video games.

Table of Contents

Preface xiii

Acknowledgments xix

About this book xxi

1 Getting Started 1

Installing Python 1

Starting Python with IDLE 2

Instructions, please 3

Interacting with Python 5

Time to program 7

Running your first program 8

If something goes wrong 9

Your second program 11

2 Remember This-Memory and Variables 14

Input, processing, output 14

Names 16

What's in a name? 20

Numbers and strings 21

How "variable" are they? 22

The new me 23

3 Basic Math 26

The four basic operations 27

Operators 28

Order of operations 29

Two more operators 30

Really big and really small 33

4 Types of Data 38

Changing types 38

Getting more information: type() 41

Type-conversion errors 42

Using type conversions 42

5 Input 44

raw_input () 45

The print command and the comma 45

Inputting numbers 47

Input from the Web 49

6 GUIs-Graphical User Interfaces 52

What's a GUI? 52

Our first GUI 53

GUI input 54

Pick your flavor 55

The number-guessing game ... again 59

Other GUI pieces 60

7 Decisions, Decisions 62

Testing, testing 62

Indenting 65

Am I seeing double? 65

Other kinds of tests 66

What happens if the test is false? 67

Testing for more than one condition 69

Using "and" 69

Using "or" 70

Using "not" 70

8 Loop the Loop 74

Counting loops 75

Using a counting loop 77

A shortcut-range () 78

A matter of style-loop variable names 80

Counting by steps 82

Counting without numbers 84

While we're on the subject ... 84

Bailing out of a loop-break and continue 85

9 Just for You-Comments 89

Adding comments 89

Single-line comments 90

End-of-line comments 90

Multiline comments 90

Commenting style91

Commenting out 92

10 Game Time 94

Skier 94

11 Nested and Variable Loops 99

Nested loops 99

Variable loops 101

Variable nested loops 102

Even more variable nested loops 103

Using nested loops 105

12 Collecting Things Together-Lists 112

What's a list? 112

Creating a list 113

Adding things to a list 113

What's the dot? 114

Lists can hold anything 114

Getting items from a list 115

"Slicing" a list 116

Modifying items 118

Other ways of adding to a list 118

Deleting from a list 120

Searching a list 121

Looping through a list 122

Sorting lists 123

Mutable and immutable 126

Lists of lists: tables of data 126

13 Functions 131

Functions-the building blocks 131

Calling a function 133

Passing arguments to a function 134

Functions with more than one argument 137

Functions that return a value 139

Variable scope 140

Forcing a global 143

A bit of advice on naming variables 144

14 Objects 146

Objects in the real world 147

Objects in Python 147

Object = attributes + methods 148

What's the dot? 149

Creating objects 149

An example class-HotDog 154

Hiding the data 159

Polymorphism and inheritance 159

Thinking ahead 162

15 Modules 164

What's a module? 164

Why use modules? 164

Buckets of blocks 165

How do we create modules? 165

How do we use modules? 166

Namespaces 167

Standard modules 170

16 Graphics 174

Getting some help-Pygame 174

A Pygame window 175

Drawing in the window 178

Individual pixels 186

Images 190

Let's get moving! 192

Animation 193

Smoother animation 194

Bouncing the ball 196

Wrapping the ball 198

17 Sprites and Collision Detection 202

Sprites 202

Bump! Collision detection 208

Counting time 212

18 A New Kind of Input-Events 217

Events 217

Keyboard events 219

Mouse events 223

Timer events 225

Time for another game-PyPong 227

19 Sound 239

More help from Pygame-mixer 239

Making sounds versus playing sounds 240

Playing sounds 240

Controlling volume 243

Repeating music 245

Adding sounds to PyPong 245

More wacky sounds 246

Adding music to PyPong 250

20 More GUIs 254

Working with PythonCard 254

Components 255

Making our GUI do something 258

The return of event handlers 259

Moving the button 260

More useful GUIs 260

TempGUI 261

What's on the menu? 266

21 Print Formatting and Strings 273

New lines 274

Horizontal spacing-tabs 275

Inserting variables in strings 277

Number formatting 278

Strings 'n' things 282

22 File Input and Output 290

What's a file? 291

Filenames 291

File locations 292

Opening a file 296

Reading a file 297

Text files and binary files 299

Writing to a file 300

Saving your stuff in files: pickle 303

Game time again-Hangman 305

23 Take a Chance-Randomness 313

What's randomness? 313

Rolling the dice 314

Creating a deck of cards 319

Crazy Eights 323

24 Computer Simulations 336

Modeling the real world 336

Lunar Lander 337

Keeping time 342

Time objects 343

Saving time to a file 347

Virtual Pet 349

25 What's Next? 358

General programming 358

Python 359

Game programming and Pygame 359

Other Python stuff 360

Look around 362

Appendix A Variable Naming Rules 363

Answers to Self-Test Questions 365

Chapter 1 Getting Started 365

Chapter 2 Remember This-Memory and Variables 366

Chapter 3 Basic Math 367

Chapter 4 Types of Data 368

Chapter 5 Input 369

Chapter 6 GUIs-Graphical User Interfaces 371

Chapter 7 Decisions, Decisions 372

Chapter 8 Loop the Loop 374

Chapter 9 Just for You-Comments 375

Chapter 10 Game Time 376

Chapter 11 Nested and Variable Loops 376

Chapter 12 Collecting Things Together-Lists 377

Chapter 13 Functions 379

Chapter 14 Objects 380

Chapter 15 Modules 382

Chapter 16 Graphics 383

Chapter 17 Sprites and Collision Detection 385

Chapter 18 A New Kind of Input-Events 385

Chapter 19 Sound 386

Chapter 20 More GUIs 386

Chapter 21 Print Formatting and Strings 387

Chapter 22 File Input and Output 388

Chapter 23 Take a Chance-Randomness 390

Chapter 24 Computer Simulations 391

Index 393

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews

Hello World!: Computer Programming for Kids and Other Beginners 4 out of 5 based on 0 ratings. 6 reviews.
creativejenny More than 1 year ago
My 10 year old son was very interested in computer programming and I blindly bought this book online. Little did I know what a great book I was buying! I can tell you he has thoroughly enjoyed it and I am simply amazed at what he can now do! He was literally programming after a couple of chapters! He finds the language easy to understand and all of the programs he has tried so far work just like the authors said they would. He has high expectations and gets easily disappointed so I was very relieved when his first experience turned out to be a good one. He spends hours of his free time on this and he has read each chapter in order while trying out the different programs. If you are looking for an informative book, I highly recommend this one.
HeyJoe More than 1 year ago
HELLO WORLD! takes me back 45 years, when I learned to program in BASIC on Atari and Commodore 64 and Tandy TRS 80/100 computers. While BASIC allowed me to develop some marine navigation assistance programs as well as artistic screen programs, I fell out of the game when it came to using the more complex programming languages. HELLO WORLD! teaches the PYTHON language in a way that makes it very understandable and interesting to kids. Showing a kid how to make things happen on screen, and simple ways of producing colors and games can make them want to do more. I have looked at other books on the PYTHON language, and they all get so complicated so quickly that they drown you in minutiae before you can make them do much of anything on the screen. (even the "for DUMMIES!" book) HELLO WORLD! is written so that children, or even old fogies like me (70), can understand whats happening when commands are properly entered. It presents the language in an easy to learn way that encourages readers to dig in and experiment.
BlueIrisNY More than 1 year ago
I'd been wanting to introduce my 9 year old to programming but not sure where to begin. This book works very well as a guide for both of us. It is easy to follow and easy to understand. My son is able to test out the sample programs the book provides and inspires him to write his own.
Anonymous More than 1 year ago
Anonymous More than 1 year ago
Anonymous More than 1 year ago