Teaching Python

John Ladasky john_ladasky at sbcglobal.net
Mon Sep 29 14:41:45 EDT 2014


I am actually teaching Python as a side job.  My students have ranged from eighth graders, up to a Silicon Valley hardware engineer who had no coding experience, but who needed to do some test engineering.

My wife is an elementary school teacher.  We occasionally talk about age-appropriate learning, and pedagogical strategies.  I once watched a research biologist try to explain restriction enzymes to my sixth-grade son.  It was painful to watch.  Sure, my son is a smart kid, but there was no way he was going to understand what she was talking about without some background.

For my younger Python students, I interact with them directly, sitting by their side while they type.  Initially, I do not ask them to read any computer documentation.  It's too difficult for them, even the official Python tutorial.   The tutorial is aimed at an adult reader who has at least a little computer experience -- and sometimes, quite a lot.  Just read Chapter 1.  Imagine that you're 14 years old, reading that.  Even if you have already programmed in one of the languages aimed at children, like Scratch, you will be in way over your head.  

Now, even though I think that the Python tutorial is too hard for young students to read, I do cover much of the MATERIAL in that tutorial, and in approximately the same order.  I sit the student down in front of the interpreter, explain what an interpreter is, and then have them type simple mathematical expressions.  I introduce variable names, and then strings, and lists.  This is, more or less, the material in Chapter 3 of the tutorial -- although lists are not discussed until Chapter 5.

Next, I introduce the idea of a program file, and have them start working with an editor.  That's not in the tutorial at all.  I introduce the print() function (briefly mentioned in Chapter 3), and the for statement (Section 4.2).  Once you introduce the for statement, you need to explain code blocks, the use of a colon at the end of a line, and the use of indentation.

This is enough information to get the student to write short programs.  I start with single loops.  Then, I have the student write a multiplication table program.  Getting the student to grasp the idea of a loop inside a loop can sometimes be challenging.

The next three things that I teach are the if statement (Section 4.1), the input() function (which appears in Chapter 4 of the tutorial, without any introduction or explanation), and string concatenation using the + operator.  This is enough to get the student to write a program which accepts an input string, and prints out an alphabetized version of that string.  I do not show the student the sorted() function until after they write the program with what they know!

Typically, I move on to the range() function and slicing operations next.  But unless you are working with very bright kids, that should be enough to keep them busy for a while.  :^)



More information about the Python-list mailing list