I'm self-taught, but here are my thoughts.
0. Language
I learned using a combination of Python (once I started to get more serious about programming, I actually don't remember how I stumbled across it) and JavaScript. Consequently, I have good indentation habits, and I haven't had to worry about problems you do have to worry about with some lower level languages. It also allows you to dabble in OOP but also not if you don't want to, which is also nice. Here's the general order of events for me, as best as I can remember it.
1. Motivation
Drawing shapes in JavaScript, printing things in Python, all stuck out to me as "whoa, cool" moments that made me want to keep going. I also saw cool projects that others had made on Khan Academy, where I started learning. It was exciting, and I wanted to be able to do all the stuff that the other users did.
2. Printing
This is almost step -1, but just thought I'd point it out here. This is also useful for the next thing.
3. Variables
Here, you can progress from
print("Hello, World!")
to
print_this = "Hello, World!"
print(print_this)
I learned using the classic buckets analogy - when you define a variable, you put something in a bucket that's labelled whatever you name the variable. When you call the variable elsewhere, the computer looks for the name, and grabs whatever's inside the bucket.
4. if
statements
This again builds off the previous concept - for example, you might do
print_this = "Hello, World!"
do_i_print = True
if do_i_print == True: #this can also be written as 'if do_i_print:'
print(print_this)
else:
print("Nobody's home!")
Project 1
All learning is more fun when it's motivated by something. With the information students have learned so far, they can now create a choose-your-own-adventure story with the introduction of one simple built-in in python - input()
. For example, a very simple one might be:
first_choice = input("Your sister is missing when you wake up. Do you go to the kitchen to eat first, or go straight out to the barn to check if she's there? Input 'barn' or 'kitchen': ")
if first_choice = 'barn':
print("You found your sister!")
elif first_choice = 'kitchen':
print("Your mom scolds you for being a glutton and sends you to do your chores. Maybe you can find your sister later.")
You might also introduce basic input sanitization, and tell them this is what working programmers have to consider.
5. Numbers/math
Previously, you've used strings in the variables. Now, generalize to other types of variables - numbers, which can be whole or with decimals (integers and floats), lists, etc. Starting with numbers, you can then teach math operations (this'll become useful in a couple of steps). For example:
my_num = 5
print(my_num**2)
6. Functions
You can now generalize the previous step -
a = 5
b = 2
def multiply(a, b):
return a*b
multiply(a, b)
Project 2
Now, a bigger project, and one they'll really enjoy (or at least, nerdy me did). If this is early highschool or middle school, they'll appreciate a program to solve quadratic equations for them. (I can provide my own, probably overly long solution if you want. Provide bonus points if they get their program to accommodate imaginary numbers. Hint: it has to do with the difference between the square root functions in math
and cmath
.)
7. More types - lists and dictionaries
Lists can be fun for later projects. Lists should probably be explained first, and then dictionaries.
8. while
loops
Here, we can do something to all the elements in a list, which flows nicely into 9 and 10.
classmates = ['Bob', 'Jerry', 'Joe', 'Anna', 'Joan', 'Teresa']
ages = []
counter = 0
while counter < len(classmates):
student = classmates[counter]
print(student)
age = input("What is the age of " + student + "?")
ages.append(age)
counter+=1
Rather a poor example, because that really should be a dictionary, but then you could I suppose do dict(zip(classmates, ages))
- either way, it's a poor scheme. I'll try to replace it if I think up something better. Anyway.
9. for
and foreach
loops
Now, this gets shorter. For loops progress from while loops:
classmates = ['Bob', 'Jerry', 'Joe', 'Anna', 'Joan', 'Teresa']
ages = []
for(i = 0; i < len(classmates); i++):
student = classmates[i]
print(student)
age = input("What is the age of " + student + "?")
ages.append(age)
Or, you could just do
classmates = ['Bob', 'Jerry', 'Joe', 'Anna', 'Joan', 'Teresa']
ages = []
for student in classmates:
print(student)
age = input("What is the age of " + student + "?")
ages.append(age)
Project 3
And now, another project! This one you can do something in the lines of codecademy's python project - using functions, dictionaries, lists, math, etc - to build a project.
10. OOP
I don't think I understand/have used OOP enough to suggest analogies/etc, but I do suggest introducing it last along with an accompanying project.
Project 4
OOP focused project.
11. Exploration
From here, perhaps let them explore. One kid might be excited for robotics, another, for the theoretical stuff, another, for scientific programming, another, game programming. Perhaps an ideal method: a unit on programming to control peripherals, using, say, the arduino, a unit on some theoretical stuff - logic gates, truth tables, and so forth, and a unit on specific programming applications - GUIs, game programming, scientific programming, websites - and allowing students to dabble in all of these.