Welcome to Computer Programming For Kids (CP4K)

Welcome to the Computer Programming for Kids blog! We are the co-authors of the book "Hello World! Computer Programming for Kids and Other Beginners", released in March 2009. The book is published by Manning Publications. Manning has a web site for the book, which is where you can download the software and other files related to the book. You can purchase it here, at the Manning web site. If you use this link to purchase the print book or e-book from the Manning web site, you can use the discount code aupromo40 at checkout to get a 40% discount. You can also get it through online retailers like Amazon, as well as in many retail locations such as Chapters in Canada and Barnes & Noble in the U.S. This blog is mostly about the book (for now), but anything related to computers and programming, particularly for kids and beginners, is fair game. We will post articles with extra material that didn't make it into the book, and reader feedback and suggestions are always welcome.

Monday, April 20, 2009

Book in hand

The printed books are finally here!

We have been waiting a long time, and we finally have the printed books in our hands. It's pretty exciting to actually see it, hold it, and turn the pages.

There was a little glitch with the printing. Due to some kind of error at the printer, some of graphics didn't print properly in the first printing. Our Production Manager at Manning, Mary Piergies, told us this was the first time this happened in the 13 years she has been working there, and she has produced hundreds of titles. So, of course, it had to happen to our book! (What are the odds...?)

But the corrected copies have now been printed. Anyone who received one of the first printings will get a corrected copy. (None of them went out to retail stores or Amazon. Some went out to people who ordered from the Manning web site.) You can make sure you have the corrected copy if you look on the copyright page (the second page inside the front cover). Near the bottom there is the ISBN number. If it is the corrected version, it says "Second corrected printing" right above the ISBN number. Any printing after that is also fine (third, fourth, etc.).

The books should be on their way to retailers now, both online and "bricks and mortar" stores. You can already order it directly form Manning using this link.

Monday, April 6, 2009

Reviews

When we set out to write a book, we had some goals and a vision for how it would turn out. Getting the book written and published was a long and winding road. (It felt, really, really, excruciatingly long at times). So, when we got to the end of it and actually had a book in our hands, we wondered if those initial goals and vision made it through to the end result. Happily, we feel they did. But of course we want to know what others think of it, too. Do kids, parents, teachers, and other readers think the book is useful, readable, and fun?

We've started getting some reviews of the book, and it is very gratifying to see that others are noticing and pointing out the very qualities that we tried hardest to include: fun and readable (but not condescending), well organized, suitable for use in schools and at home.

Here's what some reviewers are saying about the book:


Colin D. Sulin (on amazon.com):
I'm an IT veteran with nearly 25 years of programming experience in a variety of languages and technologies. This book is really one of the best that I have come across. I'm teaching my girls and this book is just perfect for the task. I'm not a Python programmer, but this book is the best thing you can get for getting kids going in computers. I highly recommend it.


Noel O'Blog:
I think this is a great book that fills a real niche. ... What's amazing is that it has set its sights so high, and yet manages to meet its goals. I think it would be great to see this book promoted as a way of teaching programming in primary schools. In the meanwhile if you know any 12+ kids interested in computers, give them an opportunity to develop a fascinating hobby and get them this book.


JR Peck (on Slashdot)
The book is formatted with lots of visuals and fly-outs that give information on how computers operate and how programming languages deal with information processing. My daughter and I have already had interesting discussions on subjects like integers and floats. An example that draws a sine wave led to a great teachable moment about amplitude and wave length. Then there is the constant need for approaching problem solving in a structured manner using logic. I think that taking on programming brings a wide number of benefits.


Bucket-O-Cool:
Hello World! Computer Programming for Kids and Other Beginners is a clear and easy-to-digest voyage through the beginnings of programming with Python. ... By having a junior author involved in the learning process, the reader can quickly identify with the questions being asked to either reinforce the concept that they have learned, or if required, cling to it like a life preserver until they come to a better understanding. It’s a good writing strategy that not only supports an even paced read and lesson, but makes the task at hand genuinely more enjoyable.


Dan Appleman (Gadgets Examiner):
"Hello World” is easy to read, well written and logically organized. ... In an unusual twist, the authors chose to use Python as their computer language. In this they made an outstanding decision. ... Beginners learn best with a kind of language called an interpreter – that allows you to experiment interactively, and Python is a fine choice. Plus the Python language is similar enough to other languages so that a kid who learns it will be able to move to others if necessary. The programming concepts that are taught in the book are easily transferrable to other languages.

The book also has a nice selection of sample programs, with an emphasis on games, but with enough variety that a broad set of concepts can be covered. And the games include graphics – which adds to the appeal.... So this is one book that I’d encourage you not just to buy for your kids, but to read and work on with them.


Cuberick.com:
These days a search for "programming for kids" on Amazon wouldn't return any interesting results, until now. A new book called "Hello World! Computer Programming for Kids and Other Beginners" has just come out. It is a book in the spirit of those old BASIC programming books. It covers the fundamentals of programming using the Python language and has game programs that you can get started with including a lunar lander game and a ski-free clone. If you want to learn programming or teach it to a kid, this is your book. Enjoy!


David Brin:
Hello World! helps challenge young people to take on technology, making it fun, without dumbing-down the adventure.


Sue Gee (I-programmer):
I'm very pleased to discover this new book written by a father and son team to help make up for a very real deficiency in the educational system. Learning to program is a mind expanding experience so while the book has been written to appeal to a young audience it has a lot to offer all beginners. It adopts a logical approach and presents clear explanations backed up by well chosen examples. This book is a very good introduction to programming and can be recommended to anyone, young or old, who wants to start learning this vital and highly enjoyable skill.


Steven Gilham (on amazon.co.uk)
Hello World! is a gentle and humorous introduction to the idea of programming, using Python, a language well suited to filling the niche that BASIC dialects did a generation ago. Even to a crusty and cynical old-timer, like myself, it makes entertaining reading -- not only is the writing style light and engaging, but you can nod sagely and think "Been there, done that" at all the "In the good old days" asides.

Trying out on members of the target audience, it has proven a hit. In its catchy and absorbing manner, it explains the fundamentals (the simple things like variable names being, well, just names) clearly and the exercises concentrate on making fun things happen sooner rather than later. The infectious enthusiasm of the author even managed to hook my non-programmer wife, and get her trying out the examples.


Illustrations

If you've looked at the book (or even just the cover), you might be wondering about the person who did all the wonderful illustrations. His name is Martin Murtonen. You can find out more about his work at his web site.

Although we worked very closely with Martin to get all the illustrations just right, we never met him, until our Book Launch party, even though we live in the same city! All our collaboration was by phone and e-mail.

That's one of the things about modern communications, and computers in particular. There are many people who work together or are friends who have never met in person. In fact, we have never met any of the people who worked on our book - editors, typesetters, production staff, and so on (except for a few reviewers who we knew before we started). One day we hope to meet some of the people who made our book come to life!

Sunday, April 5, 2009

Python Help and Your Modules

Warren: In the book, we talked a bit about Python's help system. This is something that can give you help on using Python's built-in modules and functions as well as external modules and functions. But we didn't tell you how to add help to your own modules. In this post, we will. I'm going to let Carter take it from here.

Carter: Hi! It's Carter here. This blog post is a guide to adding help to your Python modules. We will be starting with our TempConv module from Chapter 15:


# this is the file "my_module.py"
# we're going to use it in another program
def c_to_f(celsius):
fahrenheit = celsius * 9.0 / 5 + 32
return fahrenheit

First, let's see what help() brings up in Python:


>>> import my_module
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named my_module


Oops! We forgot that Python can't find our module unless it's in a folder where python can find it. Navigate to this folder in Windows Explorer (or your favourite file browser):

C:\Python25\Lib\site-packages\

Among other things, you should see a Pygame folder, a PythonCard folder, and easygui.py (you might have to scroll down). Save my_module.py there, restart IDLE (or SPE, or Python Shell), and then try importing it again to make sure Python can find it.

Now, let's see what help() brings:


>>> import my_module
>>> help(my_module)
Help on module my_module:

NAME
my_module

FILE
c:\python25\lib\site-packages\my_module.py

DESCRIPTION
# this is the file "my_module.py"
# we're going to use it in another program

FUNCTIONS
c_to_f(celsius)
# this is the file "my_module.py"
# we're going to use it in another program

Not very user-friendly. Let's try changing the comments.

# My Module
# Our first module.
def c_to_f(celsius):
#converts celsius to fahrenheit
fahrenheit = celsius * 9.0 / 5 + 32
return fahrenheit


And now restart IDLE again (this is getting annoying...) and call help():

>>>import my_module
>>>help(my_module)
Help on module my_module:

NAME
my_module
FILE
c:\python25\lib\site-packages\my_module.py
DESCRIPTION
#My Module
#Our first module.
FUNCTIONS
c_to_f(celsius)

Huh. Why didn't c_to_f's comment appear? The answer is that help() uses strings, but supports comments at the start of the program. Let's change my_module again:

"""My Module
Our first module."""

def c_to_f(celsius):
"converts celsius to fahrenheit"
fahrenheit = celsius * 9.0 / 5 + 32
return fahrenheit

And now restart IDLE and use help again:

>>> import my_module
>>> help(my_module)
Help on module my_module:

NAME
my_module
FILE
c:\python25\lib\site-packages\my_module.py

DESCRIPTION
My Module
Our first module.

FUNCTIONS
c_to_f(celsius)
converts celsius to fahrenheit


There, now that looks a lot better. Also, Python classes display similar help. Try typing this into my_module:

"""My Module
Our first module."""

def c_to_f(celsius):
"converts celsius to fahrenheit"
fahrenheit = celsius * 9.0 / 5 + 32
return fahrenheit

class SampleObject:
"Sample object"
def __init__(self, number):
"Initializes object"
self.number = number
def addOne(self):
"Adds one to the number"
self.number += 1


And the help() is:

>>> import my_module
>>> help(my_module)
Help on module my_module:

NAME
my_module

FILE
c:\python25\lib\site-packages\my_module.py

DESCRIPTION
My Module
Our first module.

CLASSES
SampleObject

class SampleObject
Sample object

Methods defined here:

__init__(self, number)
Initializes object

addOne(self)
Adds one to the number

FUNCTIONS
c_to_f(celsius)
converts celsius to fahrenheit

One more thing: For help() to work correctly, your string also has to be on the first line of your program (or function, or class, or method), and be indented correctly.
And that's how you can make your modules look great in help()!