For the last few months I’ve been running a “coding club” for my son’s sixth-grade class. Once a week, the interested students (about 2/3 of the class) stick around for an hour after school and I help them learn to program. The structure is basically like the lab part of a programming class, without the lecture. I originally had planned to do some lecturing but it soon became clear that at the end of a full day of school (these kids get on the bus around 7:00am, ugh) there was very little attention span remaining. So instead I decided to give them a sheet of problems to work on each week and I spend the hour walking around helping whoever needs help.
One of my main goals is to avoid making anyone hate programming. There are three parts to this. First, I’m not forcing them to do anything, but rather providing suggestions and guidance. Second, there’s no assessment going on. I’ve never been too comfortable with the grading part of teaching, actually. It can really get in the way of learning. Third, I’m encouraging them to work together. I’ve long noticed (starting when I was a CS student) that most learning occurs between students in the lab. Not as much learning happens in the lecture hall.
For a curriculum, we started out with turtle graphics, which I’ve always found to be wonderful. Python’s turtle library is clunkier than Logo and also is abysmally slow, but the advantages (visual debugging, many kids enjoy graphics) outweigh the problems. Fractals (Sierpinski triangle, dragon curve) were a good way to introduce recursion. We spent three or four weeks doing turtle stuff before moving on to simple crypto, which didn’t work as well. On the other hand, the students did really well with mathy code, here’s the handout from one of the math weeks.
Some observations:
- One of my favorite moments so far has been when a couple of students implemented rot13 functions and used it to send rude messages to each other.
- It’s pretty important to take a snack break.
- Although the rockstar / 10x programmer idea is out of favor, it is absolutely clear that there is a huge amount of variation (much more than 10x) in how easily a group of twenty 10-11 year olds learn programming. Some kids are teaching themselves to open files and parse text while others are stuck on basic syntax issues.
- Syntax, which computer professionals more or less learn to overlook, is hugely important.
- I’ve always disliked Python’s significant whitespace and watching kids struggle with it has made me hate it even more.
Anyhow, this has been a fun teaching exercise and hopefully it is benefiting the kids.
12 responses to “Teaching Python Informally to Kids”
How are they coping with reading error messages and debugging? There’s a teaching game called “sabotage” that sounds like a fun way of tackling this area: https://teachcomputing.wordpress.com/2013/11/23/sabotage-teach-debugging-by-stealth/
I’d say only a handful of them have really started to cope with error messages and debugging. I’ve been teaching them to look for the first line number mentioned in an error message, and to mentally execute code to try to understand what it does, and to insert prints.
Hmm, I would’ve thought that Python’s syntax would be friendly to beginners, because it’s very uncluttered compared to, say, Javascript. I guess not so much. Do you have any thoughts on what kind of syntax might work better for the kids who are struggling with it?
At some point I want to create a simple machine code that you’d hand execute on graph paper with a simple 2D memory address system (i.e. cell 0A is the upper left and 9Z is the lower right) and the output would be a picture gets drawn in the lower half of the graph paper. I think it would be a good intro to “thinking like a computer”. So, l0m9mx might mean “make a line of Xs on line M from 0 to 9”. Add in some simple branching and you’re the computer!
I also have to admit surprise at Python syntax being problematic, that’s not an issue I observed much of when teaching Python to engineering students. What I would like to know is how much of a problem the lack of static checking is for your audience. I found it very hard to get my students to trace back an error they get over here to where it actually originates over there. In fact I’ve mostly given up on the course over this issue, waiting for an opportunity to either give mypy a real shot or to replace Python with something statically checked but equally “attractive” to the non-CS population here at JHU. Do you think your students would do better if there was static type checking? (Or do you think I simply misdiagnosed the issue and it’s not really about static checking at all?)
Peter, I can’t say whether or not static checking is really the issue without more information. I’m not sure it’s so much an issue with static type-checking per se as it is with the concept of data types and data structures, which isn’t always included in non-CS classes that use programming. That said, if you are interested in a statically type-checked language that’s roughly as easy to get started with as Python, I would recommend taking a look at Go (aka GoLang).
There’s a Python API for Minecraft. I strongly suspect the kids would just eat it up.
Re: significant whitespace: Have you tried using something like “python -tt”, which enforces no tabs?
Nimrod, I haven’t tried this, it’s an interesting idea but probably tough to implement for a bunch of kids using idle on their own laptops.
I did not know about the Minecraft API. I think you’re right! Though I also think Minecraft is way out of favor for this age range, even my 4th grader says that “nobody plays it anymore.”
Peter, the static type checking is an interesting question. I really don’t know. Mostly these kids are doing pretty easy things and my sense is that static typing really only kicks in at larger scale and that compile-time failures are often not that much better than runtime failures. I would absolutely welcome a more static dialect of Python + appropriate checking tools.
The syntax issues often come down to tab/space issues and other whitespace related stuff. I’ve gotten some kids going with emacs where the python mode helps out but others are still using idle which doesn’t seem as helpful. Part of the problem is they sharing code using emails and cut-and-paste and stuff always gets screwed up somewhere.
Hmm… Just found this, might help?
http://idlex.sourceforge.net/features.html
Nimrod, thanks!