January 18, 2007

Learning to Program

Everybody should know a little programming.

Last year I visited my son's second-grade classroom to teach an hour of Logo, and it was a blast. So tomorrow, I am going to try again. This time, instead of using Logo, I will be trying to teach a small group of third-graders the basics of python.

Teaching python means that it will be a taste of real programming without the sugar-coating of "educational" software. I have two hours instead of just one, but python was designed for pros, not kids. Will the kids be able to learn it? We shall see.

Our goal will be to finish a simple game - hangman.

I have posted my Learning to Program with Python walkthrough here.

Update:

Yay, what fun. Teacher Bob MacNeal posted some pictures here.

More thoughts on teaching python below.

A Turtle versus a Command-Line

Over email, Dave Maymudes asked the same question as Nelson asks below - does the "computer as a calculator" approach capture the kids' interest? Teaching command-line programming doesn't give you the sort of graphical feedback that Logo's turtle does.

But the kids actually loved just working with the console! After I showed them how to multiply numbers, they filled the whole line with 9999s to multiply. When python actually told them the answer, they were pretty amazed. "Cool, how did it do that?" In third grade, arithmetic is still pretty novel.

Simple things like concatenating strings "red" + "yellow" into "redyellow" got laughs. And of course everybody had to try "red" * 9999999 and then press control-c when their screen filled up.

How Much Could They Follow?

The whole thing took about two and a half hours, which we split into two days (the first hour was up to about page 9). The kids worked in pairs.

They really only understood the details up to about page 11 - you can tell where the limits were because past this point the kids stopped making up their own variations and just starting following along exactly. Nesting the "if" inside the "for" was probably past the outer edge of what most of the kids were actually able to understand.

So the second hour was really more about letting the kids follow along in the process of programming rather than really understanding the details. When I was a kid I spent hours typing in Atari 800 programs I found in magazines that I didn't understand - the second hour was definitely a dose of that.

Was python easy enough? Python is very easy to read, and the kids had the "feeling" of understanding the program. But python is harder to write than it is to read. Most of the kids had trouble with the whitespace alignment needed by python, and I had to go around and fix their spacing for them in order to make it through the exercise in time.

But in the end, all the kids had a hangman game they could play. The only thing we didn't get to was the hangman-drawing fun on page 15 - we tried everything else in the deck. Maybe next time I'd start with the hangman-drawing code as the first thing to try in a script. It might help the kids understand "if" while having fun drawing funny ASCII art - maybe this would be a good thing to do with a third hour.

Kids are Good Designers

At page 13, the kids had a functional hangman game that they could play, and I asked them, "tell me what is wrong with your game?"

All the hands shot up, and they were able to immediately suggest improvements: "The game doesn't stop when you win;" "it picks the same secret word every time;" "it doesn't draw a hangman guy."

In third grade, kids attack design issues with clear eyes, totally fearless, articulate, and confident about the way things should work. It is a skill that I hope they keep as they grow up.

Was it worthwhile? I think so.

Posted by David at January 18, 2007 06:37 PM
Comments

Hai David,
Thank you very much for this tutorial. The tutorial was simple and interesting.
This post also taught how to teach someone else basics of coding. This is a good way to learn a new language.

Also thank you very much for spending time on things like this.
I feel happy now.

Posted by: arun.t at January 19, 2007 04:36 AM

Have fun! Python had its start in ABC, a language designed specifically for teaching. I wonder, though, if kids will respond to "your computer is a calculator". Logo's great since it gets kids quickly producing graphics, not to mention the "pretend you're the turtle" game.

Posted by: Nelson at January 19, 2007 09:06 AM

Would you be willing to do a write-up on the details of your classroom set up? How many computers? What kind? etc.

Posted by: Phil at January 29, 2007 01:51 PM

Phil -

I used a bunch of OS X Macs, one for each pair of kids to share, and one for me to demo on. We hooked up the demo machine to a projector.

The computers happened to be old G4 iBooks I think, but really any OS X machine will be about the same. All Macs in recent years come with the python programming language, so we didn't need to set up any special software. We used the built-in Terminal to run the code and built-in TextEdit to edit the code.

I did not use an IDE with the kids, but it might be worth investigating the next time around. If any readers have a favorite Python IDE, let me know.

Posted by: David at February 2, 2007 02:13 AM

Thank you so much for this resource. I will be sharing this with a gifted class soon!

Posted by: Mary at September 24, 2008 04:38 PM
Post a comment









Remember personal info?