Hello World! Second Edition
Computer Programming for Kids and Other Beginners
Warren Sande and Carter Sande
  • December 2013
  • ISBN 9781617290923
  • 464 pages
  • printed in color

Learning to program can't be any simpler!

Shawn Stebner, Network Engineer, Intel Corp

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.

About the book

Learn to talk to your computer in its own language! Whether you want to create a game, start a business, or solve an important problem, the first step is learning to write your own programs. Programming is a fun challenge, and it's easy to get started!

This updated and revised edition of Hello World! introduces the world of computer programming in a clear and engaging style. Written by Warren Sande and his son Carter, it is full of examples that will get you thinking and learning. 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, just the basics of using a computer. If you can start a program and save a file, you'll be off and running!

Table of Contents detailed table of contents



About this book

1. Getting Started

Installing Python

Starting Python with IDLE

Instructions, please

If it doesn’t work

Interacting with Python

Time to program

Running your first program

If something goes wrong

Syntax errors

Runtime errors

Our second program

What did you learn?

Test your knowledge

Try it out

2. Remember This: Memory and Variables

Input, processing, output


What’s in a name?

Numbers and strings

Long strings

How "variable" are they?

The new me

What did you learn?

Test your knowledge

Try it out

3. Basic Math

The four basic operations


Order of operations

Two more operators

Exponentiation—raising to a power

Modulus—getting the remainder

Increment and decrement

Really big and really small


Exponents vs. E-notation

What did you learn?

Test your knowledge

Try it out

4. Types of Data

Changing types

Changing an int to a float

Changing a float to an int

Changing a string to a float

Getting more information: type()

Type-conversion errors

Using type conversions

What did you learn?

Test your knowledge

Try it out

5. Input


The print command and the comma

A shortcut for raw_input() prompts

Inputting numbers

Using int() with raw_input()

Input from the Web

What did you learn?

Test your knowledge

Try it out

6. GUIs—Graphical User Interfaces

What’s a GUI?

Our first GUI

Installing EasyGui

The Python path

Let’s get GUI-ing

GUI input

Pick your flavor

Dialog box with multiple buttons

Choice box

Text input

Default input

What about numbers?

The number-guessing game …​ again

Other GUI pieces

What did you learn?

Test your knowledge

Try it out

7. Decisions, Decisions

Testing, testing


Am I seeing double?

Other kinds of tests

What happens if the test is false?

Testing for more than one condition

Using and

Using or

Using not

What did you learn?

Test your knowledge

Try it out

8. Loop the Loop

Counting loops

Runaway loops

What are the square brackets for?

Using a counting loop

A shortcut—`range()`

A matter of style—loop variable names

A range() shortcut

Counting by steps

Counting without numbers

While we’re on the subject…​

Bailing out of a loop—`break` and continue

Jumping ahead—`continue`

Bailing out—`break`

What did you learn?

Test your knowledge

Try it out

9. Just for You—Comments

Adding comments

Single-line comments

End-of-line comments

Multiline comments

Triple-quoted strings

Commenting style

Comments in this book

Commenting out

What did you learn?

Test your knowledge

Try it out

10. Game Time


Try it out

11. Nested and Variable Loops

Nested loops

Variable loops

Variable nested loops

Even more variable nested loops

Using nested loops

Counting calories

What did you learn?

Test your knowledge

Try it out

12. Collecting Things Together—Lists and Dictionaries

What’s a list?

Creating a list

Adding things to a list

What’s the dot?

Lists can hold anything

Getting items from a list

Why does the index start from 0, not 1?

"Slicing" a list

Slice shorthand

Modifying items

Other ways of adding to a list

Adding to the end: append()

Extending the list: extend()

Inserting an item: insert()

The difference between append() and extend()

Deleting from a list

Deleting with remove()

Deleting with del

Deleting with pop()

Searching a list

The in keyword

Finding the index

Looping through a list

Sorting lists

Sorting in reverse order

Another way to sort— sorted()

Mutable and immutable

Tuple—an immutable list

Lists of lists: tables of data

Getting a single value from the table


What did you learn?

Test your knowledge

Try it out

13. Functions

Functions—the building blocks

Creating a function

Calling a function

Passing arguments to a function

Functions with more than one argument

How many is too many?

Functions that return a value

Returning a value

Variable scope

Local variables

Global variables

Forcing a global

A bit of advice on naming variables

What did you learn?

Test your knowledge

Try it out

14. Objects

Objects in the real world

Objects in Python

What are attributes?

What are methods?

Object = attributes + methods

What’s the dot?

Creating objects

Creating an instance of an object

Initializing an object

A "magic" method: str()

What’s self?

An example class—HotDog

Hiding the data

Polymorphism and inheritance

Polymorphismsame method, different behavior

Inheritance—learning from your parents

Thinking ahead

What did you learn?

Test your knowledge

Try it out

15. Modules

What’s a module?

Why use modules?

Buckets of blocks

How do we create modules?

How do we use modules?


What’s a namespace?

Importing namespaces

Importing using from


Standard modules


Random numbers

What did you learn?

Test your knowledge

Try it out

16. Graphics

Getting some help—Pygame

A Pygame window

Drawing in the window

What’s the "flip"?

How to make a circle

Pygame surfaces

Colors in Pygame

Locations—screen coordinates

Size of shapes

Line width

Modern art?

Individual pixels

Connect the dots

Connect the dots, again

Drawing point-by-point


Let’s get moving!


Erasing images

What’s under there?

Smoother animation

Keeping the ball moving

Bouncing the ball

Bouncing in 2-D

Wrapping the ball

What did you learn?

Test your knowledge

Try it out

17. Sprites and Collision Detection


What’s a sprite?

A sprite class

A move() method

Bump! Collision detection

Rect collision vs. pixel-perfect collision

Counting time

Controlling the frame rate with pygame.time.Clock()

Checking the frame rate

Scaling the frame rate

What did you learn?

Test your knowledge

Try it out

18. A New Kind of Input—Events


The event loop

The event queue

Event handlers

Keyboard events

Key events

Repeating keys

Event names and key names

Mouse events

Timer events

Time for another game—PyPong

The ball

The paddle

Controlling the paddle

Keeping score and displaying it with pygame.font

Keeping track of lives

Adding a life counter

Game over

What did you learn?

Test your knowledge

Try it out

19. Sound

More help from Pygame—`mixer`

Making sounds vs. playing sounds

Playing sounds

Starting pygame.mixer

Controlling volume

Playing background music

Repeating music

Adding sounds to PyPong

More wacky sounds

Adding music to PyPong

What did you learn?

Test your knowledge

Try it out

20. More GUIs

Working with PyQt

Qt Designer

Adding a button

Changing the button

Saving the GUI

Making our GUI do something

The return of event handlers

What is self?

Moving the button

More useful GUIs


TempGUI components

Creating the new GUI

Converting Celsius to Fahrenheit

Converting Fahrenheit to Celsius

A small improvement

Squashing a bug

What’s on the menu?

Adding a menu item


What did you learn?

Test your knowledge

Try it out

21. Print Formatting and Strings

New lines

print and the comma

Adding our own newlines

Special printing codes

Horizontal spacing—tabs

How do we print a backslash?

Inserting variables in strings

Number formatting

Integers: %d or %i

Floating point numbers: %f or %F

E-notation: %e and %E

Automatic float or E-notation: %g and %G

How do we print a percent sign?

More than one format string

Storing formatted numbers

Formatting, the new way

The format() method

Strings 'n' things

Splitting strings

Joining strings

Searching for strings

Searching anywhere in a string: in and index()

Removing part of a string

Changing case

What did you learn?

Test your knowledge

Try it out

22. File Input and Output

What’s a file?


File locations

Finding where you are

Enough about paths!

Opening a file

Reading a file

Reading one line at a time

Going back to the start

Text files and binary files

Writing to a file

Appending to a file

Writing to a file

Writing to a file using print

Saving your stuff in files: pickle



Game time again—Hangman

The Hangman GUI

Getting words from the word list

Revealing the man

Checking the letter guesses

What did you learn?

Test your knowledge

Try it out

23. Take a Chance—Randomness

What’s randomness?

Rolling the dice

More than one die

Ten in a row

Creating a deck of cards

Shuffling the deck

A card object

Crazy Eights

The main loop

The face-up card

The active suit

The player’s turn

Displaying the hand

Getting the player’s choice

The computer’s turn

Keeping score

What did you learn?

Test your knowledge

Try it out

24. Computer Simulations

Modeling the real world

Lunar Lander

Simulating the landing

Pygame returns

Keeping time

Time objects

Difference between two times

Small pieces of time

Saving time to a file

Virtual Pet


The algorithm

Simple animation

Try, try again

What did you learn?

Test your knowledge

Try it out

25. Skier Explained

The skier

The obstacles

Creating individual obstacles

Creating a map of obstacles

What did you learn?

Try it out

26. Python Battle

Python Battle

Running Python Battle

The rules of the game

Creating a Python Battle Robot

A more complicated robot

The coordinate system



What did you learn?

Try it out

27. What’s Next?

For younger programmers


Game programming and Pygame

Other game programming (non-Python)

Keep it BASIC

Mobile apps

Look around

[[part_id_apps] = Appendixes

Appendix A: Variable Naming Rules

Appendix B: Differences Between Python 2 and 3

B.1. print

B.2. input()

B.3. Integer division

B.4. range()

B.5. Python 2 to 3 conversion

Appendix C: Answers to Self-Test Questions

List of Code Listings


What's inside

  • Explains concepts in clear language
  • Lots of pictures, cartoons, and fun examples
  • Complete set of practice questions and exercises
  • Illustrated in full color

About the reader

Hello World! uses Python, a programming language designed to be easy to learn. Using fun examples, it brings to life concepts of computing -- looping, decisions, input and output, data structures, graphics, and many more.

About the author

Warren Sande is an electronic systems engineer who uses Python both as a "do anything" scripting language and as a way to teach computers and programming. 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.

placing your order...

Don't refresh or navigate away from the page.
print book $31.99 $39.99 pBook + eBook
includes previous edition eBook
Additional shipping charges may apply
Prints and ships within 3-5 days
Hello World! Second Edition (print book) added to cart
continue shopping
go to cart

eBook $25.59 $31.99 3 formats
includes previous edition eBook
Hello World! Second Edition (eBook) added to cart
continue shopping
go to cart

Prices displayed in rupees will be charged in USD when you check out.

FREE domestic shipping on three or more pBooks