The kids at coding club have decided that we should write an implementation of pong in python. I took a look at some options, and decided tkinter was the way to go. Thus, I present a pong game broken up into stages which are hopefully understandable to an 11 year old: Operation Terrible Pong.
Category: Coding_club
More coding club
This is the second post about the coding club at my kid’s school. I was away for four weeks travelling for work and then getting sick, so I am still getting back up to speed with what the kids have been up to while I’ve been away. This post is an attempt to gather some resources that I hope will be useful during the session today — it remains to be seen how this maps to what the kids actually did while I was away.
First off, the adults have decided to give Python for Kids a go as a teaching resource. The biggest catch with this book is that its kind of expensive — at AUD $35 a copy, we can’t just issue a copy to every kid in the room. That said, perhaps the kids don’t each need a copy, as long as the adults are just using it as a guide for what things to cover.
It appears that while I was away chapters 1 through 4 have been covered. 1 is about install python, and then 2-3 are language construct introductions. This is things like what a variable is, mathematical operators, strings, tuples and lists. So, that’s all important but kind of dull. On the other hand, chapter 4 covers turtle graphics, which I didn’t even realize that python had a module for.
I have fond memories of doing logo graphics as a kid at school. Back in my day we’d sometimes even use actual robots to do some of the graphics, although most of it was simulated on Apple II machines of various forms. I think its important to let the kids of today know that these strange exercises they’re doing used to relate to physical hardware that schools actually owned. Here are a couple of indicative pictures stolen from the Internet:


So, I think that’s what we’ll keep going with this week — I’ll let the kids explain where they got to with turtle graphics and then we’ll see how far we can take that without it becoming a chore.
Coding club day one: a simple number guessing game in python
I’ve recently become involved in a new computer programming club at my kids’ school. The club runs on Friday afternoons after school and is still very new so we’re still working through exactly what it will look like long term. These are my thoughts on the content from this first session. The point of this first lesson was to approach a programming problem where every child stood a reasonable chance of finishing in the allotted 90 minutes. Many of the children had never programmed before, so the program had to be kept deliberately small. Additionally, this was a chance to demonstrate how literal computers are about the instructions they’re given — there is no room for intuition on the part of the machine here, it does exactly what you ask of it.
The task: write a python program which picks a random number between zero and ten. Ask the user to guess the number the program has picked, with the program telling the user if they are high, low, or right.
We then brainstormed the things we’d need to know how to do to make this program work. We came up with:
- How do we get a random number?
- What is a variable?
- What are data types?
- What is an integer? Why does that matter?
- How do we get user input?
- How do we do comparisons? What is a conditional?
- What are the possible states for the game?
- What is an exception? Why did I get one? How do I read it?
With that done, we were ready to start programming. This was done with a series of steps that we walked through as a group — let’s all print hello work. Now let’s generate a random number and print it. Ok, cool, now let’s do input from a user. Now how do we compare that with the random number? Finally, how do we do a loop which keeps prompting until the user guesses the random number?
For each of these a code snippet was written on the whiteboard and explained. It was up to the students to put them together into a program which actually works.
Due to limitations in the school’s operating environment (no local python installation and repl.it not working due to firewalling) we used codeskulptor.org for this exercise. The code that the kids ended up with looks like this:
import random # Pick a random number number = random.randint(0, 10) # Now ask for guesses until the correct guess is made done = False while not done: guess = int(raw_input('What is your guess?')) print 'You guessed: %d' % guess if guess < number: print 'Higher!' elif guess > number: print 'Lower!' else: print 'Right!' done = True
The plan for next session (tomorrow, in the first week of term two) is to recap what we did at the end of last term and explore this program to make sure everyone understands how it works.