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.
Tuesday, June 29, 2010
Carter Teaches Random
Dave Briccetti, who, among other things, teaches programming to kids, is teaching a Python class for Grade 7-9 students this summer at College for Kids. He asked if we would be interested in doing a "guest lecture" to his class. So Carter presented an introduction to randomness and the Python Random module. You can see the video on Dave's site, here:
http://young-programmers.blogspot.com/2010/06/randomness-in-python-lesson-by-carter.html
Labels:
College for Kids,
Dave Briccetti,
Hello World,
python,
random,
randomness
Monday, June 7, 2010
Carter's VPython Podcast
A couple of weeks ago, Carter did a podcast on VPython (Visual Python), a module to create 3D graphics. You can see it here:
For our next podcast, Carter will be answering questions from readers. So, please post any questions you have about Python or related modules in our Author Forum, at:
http://www.manning-sandbox.com/thread.jspa?threadID=38048&stqc=true
Warren and Carter
For our next podcast, Carter will be answering questions from readers. So, please post any questions you have about Python or related modules in our Author Forum, at:
http://www.manning-sandbox.com/thread.jspa?threadID=38048&stqc=true
Warren and Carter
Thursday, March 11, 2010
Passing arguments as a list
In the Author Forum on the Manning page for the book, someone asked about passing arguments to a function as a list. Since posting code on that forum doesn't work well, I thought I would post the answer here.
If you are passing a number of arguments to a function, you could pass them as individual arguments, like this:
Then you would call the function like this:
But that has a couple of disadvantages. First, if there are a lot of arguments, it gets messy to type all the variable names. Second, you might not know ahead of time how many arguments you want to pass.
So, another way, that solves both those problems, is to pass a list of arguments instead, like this:
Then you would call the function like this:
In the first example, you are passing 5 separate arguments. In the second example, you are passing a single list. That list happens to have 5 items, in this example. But it would work with any number of items. For example, this would work just fine when calling the second version of the function:
These are very simple examples. You can pass things more complicated than lists. You can pass nested lists (lists of lists, or two-dimensional lists). You can pass objects, which can contain any data structure you care to define. You can pass lists of objects or objects containing lists (or dictionaries, or any other Python data type).
If you are passing a number of arguments to a function, you could pass them as individual arguments, like this:
def printMyLuckyNumbers(num1, num2, num3, num4, num5):
print "Here are your lucky numbers:"
print num1, num2, num3, num4, num5
Then you would call the function like this:
printMyLuckyNumbers(3, 7, 10, 14, 27)
But that has a couple of disadvantages. First, if there are a lot of arguments, it gets messy to type all the variable names. Second, you might not know ahead of time how many arguments you want to pass.
So, another way, that solves both those problems, is to pass a list of arguments instead, like this:
def printMyLuckyNumbers(myNums):
print "Your lucky numbers are:"
for num in myNums:
print num,
Then you would call the function like this:
myLuckyNumbers = [3, 7, 10, 14, 27]
printMyLuckyNumbers(myLuckyNumbers)
In the first example, you are passing 5 separate arguments. In the second example, you are passing a single list. That list happens to have 5 items, in this example. But it would work with any number of items. For example, this would work just fine when calling the second version of the function:
myLuckyNums = [2, 3, 5, 7, 10, 27, 32, 45]
printMyLuckyNumbers(myLuckyNums)
These are very simple examples. You can pass things more complicated than lists. You can pass nested lists (lists of lists, or two-dimensional lists). You can pass objects, which can contain any data structure you care to define. You can pass lists of objects or objects containing lists (or dictionaries, or any other Python data type).
Labels:
arguments,
functions,
Hello World,
kids,
lists,
passing,
programming,
python
Thursday, January 14, 2010
Hello World! on HanselMinutes
Carter and Warren recently appeared on the HanselMinutes podcast. Hanselminutes is a weekly audio show with web technology blogger Scott Hanselman.

You can find the podcast here.
You can find the podcast here.
Labels:
Hanselminutes,
Hello World,
podcast,
Scott Hanselman
Saturday, January 2, 2010
Hello World! German Translation
We recently discovered that there is a German translation of "Hello World!" We found it on the amazon.co.uk site.

You can see some sample chapters here:
Table of Contents
Preface
Chapter 1
Oddly, our publisher, Manning, didn't tell us about the translation. We just stumbled across it ourselves. The publishing world sometimes works in strange and mysterious ways!
You can see some sample chapters here:
Table of Contents
Preface
Chapter 1
Oddly, our publisher, Manning, didn't tell us about the translation. We just stumbled across it ourselves. The publishing world sometimes works in strange and mysterious ways!
Labels:
beginners,
book,
german,
Hello World,
kids,
programming,
translation
Tuesday, November 10, 2009
Carter Explains PythonCard on Young Programmer's Podcast
A fellow named Dave Briccetti has a site dedicated to young programmers. Part of that site is the Young Programmers Podcast.
Carter recently did a Podcast on PythonCard for the Young Programmer's Podcast. Dave tells us it's one of the most popular items on the podcast!

You can see it here.
Carter recently did a Podcast on PythonCard for the Young Programmer's Podcast. Dave tells us it's one of the most popular items on the podcast!

You can see it here.
Labels:
Carter,
Dave Briccetti,
podcast,
programmers,
PythonCard,
young
Tuesday, June 30, 2009
Carter and Warren on TV
We hosted a Book Launch party on June 24, 2009.
That day, we also did an interview on the Ottawa CTV affiliate, CJOH, with anchor Carol-Anne Meehan.
It ran on their 6:00 news. You can see it here:
http://watch.ctv.ca/news/clip186877#clip186877
You can also read the article EMC newspaper wrote about us. Reporter Sabine Gibbins talked to Carter, Warren, and illustrator Martin Murtonen the day of the launch.
We also met Martin for the first time that day. All our work together on the book had been done by e-mail and phone, even though we live in the same city!
Subscribe to:
Posts (Atom)