Most textbooks start with print("Hello World"). It is correct, and no child has ever been excited by it, because nothing responds to them.
A good first program needs three things
- It takes input from the child — so it feels like a conversation
- It answers differently depending on the input — so they see it decide
- It fits in ten lines — so they finish before their attention does
The program I actually teach
name = input("What is your name? ")
age = int(input("How old are you? "))
print("Hello " + name + "!")
if age >= 10:
print("Plenty old enough for Python")
else:
print("Young — and clearly clever")
print("In ten years " + name + " will be", age + 10)
The child types their own name and watches the computer say it back. Hello World cannot give them that.
What those ten lines actually teach
| Concept | Where it appears |
|---|---|
| Variables | name and age |
| Reading input | input() |
| Types and conversion | why int() is needed |
| Conditions | if / else |
| Arithmetic in code | age + 10 |
Let them modify it immediately
This is the important part. Once it runs, do not move to the next lesson. Have them change it:
- Ask for a favourite colour and use it in the greeting
- Add a third case with
elif - Work out how many years until they turn 60
Children who edit their own code on day one come back to the computer the next day. Children who only copied from a book usually do not.
The error you will meet first
ValueError: invalid literal for int() — they typed letters into the age question. Tell them "the computer asked for a number and you gave it letters". No jargon required; they understand at once.
To see where children go after this point, look at real student Python projects — games, generators and quizzes they designed themselves.