🚀 Python Engineer Path · session 1 of 48 · 60 minutes · free
Skill check: trace, predict and debug
Before new topics, we find out exactly how you think. You'll trace programs one line at a time, predict before you run, read error messages like an engineer and rebuild part of a task manager with functions, all without AI. By the end we both know your strengths and your next three lessons.

A complete lesson · 60 minutes
Teach it, see it, practise it, all on this page.
Open this page with your learner and work down it, or press Teach this lesson to go through it one step at a time on a big screen. Every section has something to do.
- Warm-up3 min
- Warm-up games4 min
- Trace it10 min
- Conditions you can prove9 min
- Debug without AI9 min
- Functions9 min
- FizzBuzz skill check5 min
- Debug the task manager5 min
- Grade report3 min
- Quiz2 min
- Set the project1 min
By the end you can
- Trace a program's state line by line and predict loops, accumulators, counters and flags
- Order conditions so they are provably right, and test the boundaries
- Debug from the error message: read it, find the line, form a guess, test it
- Split a task manager into small functions that return values
Before you start
- Variables, if, loops, lists, dictionaries and functions, used at least once
- A small project of your own, even if AI helped
Have ready
- This page: every code box runs, and 🔍 Dry run steps through it
- Paper for one trace table
- Your own task manager code, to look at together
Ages 13 to 17 · after the basics · one 60-minute class a week
Warm-up · think first
Without running it: total = 0, then for n in range(1, 5): total = total + n. What is total at the end, and how many times did the loop run?
Show the answer
10, after 4 passes: n is 1, 2, 3 and 4, because range(1, 5) stops before 5. If you said 15, you counted the 5: the classic off-by-one.
Teacher tip: Ask for the answer before anyone runs it. Then ask how they got it: in their head, on fingers or on paper?
🎮 Warm-up games · 5 quick games
Play with Bolt the robot
Five minutes with Bolt the robot. Vote, say why, then show the answer.
- Which one prints something different from the other three? (print(len([0, 0, 0])) · print(2 + 2) · print(len('four')) · print(8 // 2))
Answer: print(len([0, 0, 0])). It prints 3, and the other three print 4. - range(1, 10) includes 10. (Always · Sometimes · Never)
Answer: Never — Never: range stops before the stop value, so range(1, 10) is 1 to 9. - Would you rather fix a bug with an error message, or a bug where the program runs but gives the wrong answer? (A bug with an error message · A wrong answer, no error)
Answer: An error message is the easier bug: it tells you the line and the type. A wrong answer with no error needs tracing. - x = 5, then x = x * 2, then x = x - 3. What is x?
Answer: 7: 5, then 10, then 7. Each line uses the value from the line before. - When you get stuck, what do you do first?
Answer: Engineers read the error, then look at the state: print a value, or step through it. Asking AI to explain is fine; asking it to write the fix skips the learning.
Three levels, like a real engineer
Use it. Tweak it. Build it.
First use what the lesson shows exactly as it is, then change one key thing and see what happens, then make your own.
- 🔒
Level 1 · Use it
Run it as it is
Run the lesson's example program exactly as written and watch what it prints or draws.
- 🔧
Level 2 · Tweak it
Change one value
Change one number or word in that program. Say what will happen first, then run it and check.
- 🛠️
Level 3 · Build it
Write your own
Write a short program of your own that uses today's idea, and test it until it works.
🗺️ Play the Lesson QuestThree worlds, one for each level, with short stages that bring back what you miss.
Part 1 of 4 · learn, see, practise
Trace it: the state of a program
A program's state is the value of every variable at one moment. Tracing means running the program yourself, one line at a time, and writing the state down after each line. It is the most useful debugging skill there is, and it is exactly what a debugger does for professional engineers.
Use a trace table: one column per variable and one row for every line that runs. A loop adds rows on every pass. Never jump ahead to the answer: the bug is almost always in the row you skipped.
Most loops follow one of three patterns. An accumulator (total = total + x) grows. A counter (count += 1) counts the times something is true. A flag (found = True) flips once and stays. Name the pattern, and you can predict the final value before you run it.
range(a, b) starts at a and stops before b. Off-by-one bugs live in three places: the start, the stop, and a < that should be <=. When a loop is wrong, trace its first pass and its last pass.
- State = every variable's value at one moment.
- One row per line that runs. Never skip.
- range(a, b) stops before b.
Accumulator: starts at 0 (or '' or []) and grows.
Counter: += 1 only when the condition is true.
Flag: starts False and flips to True once.
First pass, last pass: most loop bugs show up there.
▶ Output
10
📦 Memory boxes
10intn4intFill a trace table on paper first: n is 1, 2, 3, 4 and total is 1, 3, 6, 10. Then press 🔍 Dry run and check every row. Change range(1, 5) to range(1, 6) and predict the new total.
Dry run: predict, then step
Each program really runs. Before every 🤔 line, predict the value, then press Next and check.
- Step through every program: predict before each 🤔 line.
Practise it
Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.
1.1 Fix the off-by-one so it prints the sum of 1 to 10, which is 55.
▶ Output
45
📦 Memory boxes
45intn9int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 1 line the student writes
total = 0for n in range(1, 11): total = total + nprint(total)
What it prints
55
What ✓ Check looks for
- it prints exactly:
55
1.2 Count how many scores are above 50 and print the count (3).
▶ Output
6
📦 Memory boxes
[12, 75, 50, 98, 3, 61]listcount6ints61int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 1 line the student writes
scores = [12, 75, 50, 98, 3, 61]count = 0for s in scores: if s > 50: count = count + 1print(count)
What it prints
3
What ✓ Check looks for
- it prints exactly:
3
1.3 Build the word backwards with a loop (no slicing): print CBA.
▶ Output
ABC
📦 Memory boxes
'ABC'strback'ABC'strch'C'str🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 1 line the student writes
word = "ABC"back = ""for ch in word: back = ch + backprint(back)
What it prints
CBA
What ✓ Check looks for
- it prints exactly:
CBA
- In the code: it uses what the lesson teaches
1.4 Use a flag: print found if any word starts with q, otherwise none.
▶ Output
none
📦 Memory boxes
['apple', 'quiz', 'tree']listfoundFalseboolw'tree'str🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
words = ["apple", "quiz", "tree"]found = Falsefor w in words: if w.startswith("q"): found = Trueprint("found" if found else "none")
What it prints
found
What ✓ Check looks for
- it prints exactly:
found
1.5 Without max() or index(): print the largest number and its position, like 98 at 3.
▶ Output
0 at 0
📦 Memory boxes
[12, 75, 50, 98, 3, 61]listbest0intpos0int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 5 lines the student writes
nums = [12, 75, 50, 98, 3, 61]best = nums[0]pos = 0for i in range(len(nums)): if nums[i] > best: best = nums[i] pos = iprint(best, "at", pos)
What it prints
98 at 3
What ✓ Check looks for
- it prints exactly:
98 at 3
- In the code: it uses what the lesson teaches
1.6 Nested loops: print a 3 by 4 times grid, one row per line (1 2 3 4, then 2 4 6 8, then 3 6 9 12).
▶ Output
📦 Memory boxes
3introw''str🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 3 lines the student writes
for r in range(1, 4): row = "" for c in range(1, 5): row = row + str(r * c) + " " print(row.strip())
What it prints
1 2 3 4 2 4 6 8 3 6 9 12
What ✓ Check looks for
- it prints exactly:
1 2 3 4 2 4 6 8 3 6 9 12
Part 2 of 4 · learn, see, practise
Conditions you can prove
An if/elif/else chain checks its conditions from the top, and only the FIRST true branch runs. So the order is part of the logic: check the strictest condition first. if score >= 50 before elif score >= 90 means nobody ever gets the 90 branch.
and needs both sides true; or needs one; not flips. Python stops early (short-circuit): in x != 0 and 10 / x > 2, the division never runs when x is 0. That is a safe way to guard a risky check.
Test the boundaries, not just a typical value. For if age >= 13, test 12, 13 and 14. One value below the line, one on it and one above proves the condition; a random value proves nothing.
Turn a rule into a condition one clause at a time. 'A leap year is divisible by 4, except centuries, unless divisible by 400' becomes (y % 4 == 0 and y % 100 != 0) or y % 400 == 0.
- The first true branch wins: strictest first.
- Test below, on and above the boundary.
- and / or stop early: use that as a guard.
Truthy: non-empty strings and lists, non-zero numbers. Falsy: '', [], 0, None, False.
a < x < b works in Python: it means a < x and x < b.
Write the rule in words before you write the condition.
▶ Output
pass
📦 Memory boxes
95intIt prints pass for 95. Why? Swap the first two branches so 95 prints distinction, then test 49, 50, 89, 90 and 91.
Puzzle break: prove it
Hands off the keyboard: decide first, then check with ▶ Run or 🔍 Dry run.
- Puzzle 1: say what happens before you run it
- Puzzle 2: say what happens before you run it
- Puzzle 3: find the bug
Practise it
Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.
2.1 Ticket prices: under 12 pays 50, 60 or over pays 70, everyone else 100. Make price() right for 10, 30 and 65.
▶ Output
50 100 100
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
def price(age): if age < 12: return 50 elif age >= 60: return 70 return 100 print(price(10), price(30), price(65))
What it prints
50 100 70
What ✓ Check looks for
- it prints exactly:
50 100 70
2.2 Fix the order of the branches so 85 gets an A (A is 80 or more, B is 60 or more).
▶ Output
B B C
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
def band(score): if score >= 80: return "A" elif score >= 60: return "B" return "C" print(band(85), band(70), band(40))
What it prints
A B C
What ✓ Check looks for
- it prints exactly:
A B C
2.3 Test the boundary: print whether 12, 13 and 19 are teens (13 to 19).
▶ Output
False False False
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 1 line the student writes
def is_teen(age): return 13 <= age <= 19 print(is_teen(12), is_teen(13), is_teen(19))
What it prints
False True True
What ✓ Check looks for
- it prints exactly:
False True True
2.4 Guard against dividing by zero: safe_ratio(10, 0) returns 0 and safe_ratio(10, 4) returns 2.5.
▶ Output
2.5 Line 2: ZeroDivisionError: division by zero
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
def safe_ratio(a, b): if b == 0: return 0 return a / b print(safe_ratio(10, 4))print(safe_ratio(10, 0))
What it prints
2.5 0
What ✓ Check looks for
- it prints exactly:
2.5 0
2.5 Leap years: divisible by 4, except centuries, unless divisible by 400. Print the answers for 2024, 1900, 2000 and 2023.
▶ Output
True True True False
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 1 line the student writes
def is_leap(y): return (y % 4 == 0 and y % 100 != 0) or y % 400 == 0 print(is_leap(2024), is_leap(1900), is_leap(2000), is_leap(2023))
What it prints
True False True False
What ✓ Check looks for
- it prints exactly:
True False True False
2.6 A valid username is 3 to 12 characters, letters or digits only, and does not start with a digit. Check four names.
▶ Output
True True True True
📦 Memory boxes
'Aarush2026'str🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 1 line the student writes
def valid(name): return 3 <= len(name) <= 12 and name.isalnum() and not name[0].isdigit() for n in ["ash", "9lives", "a_b", "Aarush2026"]: print(valid(n))
What it prints
True False False True
What ✓ Check looks for
- it prints exactly:
True False False True
Part 3 of 4 · learn, see, practise
Debug without AI: read the error, find the line
An error message is a gift: it tells you the line and the kind of problem. Read it from the bottom. 'Line 3: IndexError: list index out of range' means: on line 3, you asked a list for a position it does not have.
Learn the usual suspects. NameError: a misspelt or undefined name. TypeError: mixing types, like 'Age: ' + 14. IndexError: a position past the end. KeyError: a missing dictionary key. ValueError: int('abc'). ZeroDivisionError: dividing by zero.
When there is no error but the answer is wrong, debug like a scientist: reproduce it, guess the cause, then test the guess by looking at the state (print the variables, or use 🔍 Dry run). Change one thing at a time and run again.
Use AI like a senior engineer you can ask for hints: 'What does this error mean?' or 'What should I check?' Never 'fix it for me'. If you can't explain the fix, it isn't your fix yet.
- Read the error from the bottom: the line and the type.
- No error but a wrong answer? Trace the state.
- Change one thing, run again.
'Age: ' + str(14), or f'Age: {age}', fixes the classic TypeError.
d.get(key, 0) never raises KeyError.
Rubber duck: explain your code line by line out loud. The bug often appears halfway through.
▶ Output
90 80 70 Line 3: IndexError: list index out of range
📦 Memory boxes
[90, 80, 70]listi3intRun it and read the error: which line, which kind? Trace i on its last pass. Fix the range so it prints all three scores and stops.
Puzzle break: bug hunt
Find each bug with your eyes first. Then fix it in a code box to prove it.
- Puzzle 1: find the bug
- Puzzle 2: find the bug
- Puzzle 3: find the bug
Practise it
Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.
3.1 Fix the NameError so it prints Hello, Aarush.
▶ Output
Line 2: NameError: name 'nmae' is not defined
📦 Memory boxes
'Aarush'str🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 1 line the student writes
name = "Aarush"print("Hello, " + name)
What it prints
Hello, Aarush
What ✓ Check looks for
- it prints exactly:
Hello, Aarush
3.2 Fix the TypeError so it prints Level: 4.
▶ Output
Line 2: TypeError: can only concatenate str (not "int") to str
📦 Memory boxes
4int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 1 line the student writes
level = 4print("Level: " + str(level))
What it prints
Level: 4
What ✓ Check looks for
- it prints exactly:
Level: 4
3.3 Fix the KeyError: print 3 for pen and 0 for pencil, without changing the dictionary.
▶ Output
3 Line 3: KeyError: 'pencil'
📦 Memory boxes
{'pen': 3, 'book': 5}dictitem'pencil'str🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 1 line the student writes
stock = {"pen": 3, "book": 5}for item in ["pen", "pencil"]: print(stock.get(item, 0))
What it prints
3 0
What ✓ Check looks for
- it prints exactly:
3 0
- In the code: it uses what the lesson teaches
3.4 No error, wrong answer: the average of 80, 90 and 75 should be 81.67. Find the bug.
▶ Output
25.0
📦 Memory boxes
[80, 90, 75]listtotal75intm75int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 1 line the student writes
marks = [80, 90, 75]total = 0for m in marks: total = total + mprint(round(total / len(marks), 2))
What it prints
81.67
What ✓ Check looks for
- it prints exactly:
81.67
3.5 Two bugs: it should print each task with its number (1. Read, 2. Code, 3. Sleep), then Done.
▶ Output
Line 3: TypeError: unsupported operand type(s) for +: 'int' and 'str'
📦 Memory boxes
['Read', 'Code', 'Sleep']listi1int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
tasks = ["Read", "Code", "Sleep"]for i in range(len(tasks)): print(str(i + 1) + ". " + tasks[i])print("Done")
What it prints
1. Read 2. Code 3. Sleep Done
What ✓ Check looks for
- it prints exactly:
1. Read 2. Code 3. Sleep Done
3.6 Handle bad input: ask for an age, print Next year: N, or Please type a number if it isn't a number.
▶ Output
Age? 14 Next year: 15
📦 Memory boxes
14int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 5 lines the student writes
text = input("Age? ")try: age = int(text) print("Next year:", age + 1)except ValueError: print("Please type a number")
What it prints when they type 14
Age? 14 Next year: 15
What ✓ Check looks for
- When they type
14, the output includesNext year: 15 - When they type
fourteen, the output includesPlease type a number
Part 4 of 4 · learn, see, practise
Functions: split a big program into small ones
A function is a small machine: inputs go in as parameters, and one result comes out with return. print shows something on the screen; return hands a value back to the code that called the function, so it can be used, stored or tested.
Give every function one job. In a task manager, add_task adds, list_tasks formats, top_task picks the most urgent. Small functions are easy to read, easy to test and easy to reuse in the next version.
A function that only uses its parameters and returns a value (no input(), no print, no global changes) is pure. Pure functions can be tested with one line: assert average([2, 4]) == 3. Engineers write those tests before they trust the code.
Choose your data first. A task is a dictionary: {'title': 'Read', 'priority': 2, 'done': False}. The task list is a list of those dictionaries. When the data shape is clear, the functions almost write themselves.
- return gives the value back; print only shows it.
- One function, one job.
- Pure functions can be tested with assert.
Default values: def add_task(tasks, title, priority=3).
Return early for the special case: if not nums: return 0.
A list of dictionaries is how JSON files store records, like your task manager's save file.
▶ Output
2 Homework
📦 Memory boxes
[{'title': 'Homework', 'priority': 1}, {'title': 'Gaming', 'priority': 3}]listPress 🔍 Dry run and watch the list of dictionaries grow. Then add a third task and print its title.
Dry run: a function call
Watch the call jump into the function, change the list, and come back.
- Step through every program: predict before each 🤔 line.
Practise it
Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.
4.1 Write is_even(n) so it returns True or False. Print it for 4 and 7.
▶ Output
True False None None
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 1 line the student writes
def is_even(n): return n % 2 == 0 print(is_even(4), is_even(7))
What it prints
True False
What ✓ Check looks for
- it prints exactly:
True False
4.2 average(nums) returns the mean, and 0 for an empty list. Print it for [2, 4, 9] and [].
▶ Output
5.0 Line 2: ZeroDivisionError: division by zero
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
def average(nums): if not nums: return 0 return sum(nums) / len(nums) print(average([2, 4, 9]))print(average([]))
What it prints
5.0 0
What ✓ Check looks for
- it prints exactly:
5.0 0
4.3 Finish add_task so it stores a dictionary with title, priority and done (False). Print the count and the last title.
▶ Output
Line 7: IndexError: list index out of range
📦 Memory boxes
[]list🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
def add_task(tasks, title, priority): tasks.append({"title": title, "priority": priority, "done": False}) return tasks tasks = []add_task(tasks, "Read", 2)add_task(tasks, "Code", 1)print(len(tasks), tasks[-1]["title"], tasks[-1]["done"])
What it prints
2 Code False
What ✓ Check looks for
- it prints exactly:
2 Code False
4.4 Write format_task(t) so a task prints like [ ] Read (p2), or [x] when done.
▶ Output
Read Gym
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
def format_task(t): box = "[x]" if t["done"] else "[ ]" return f"{box} {t['title']} (p{t['priority']})" print(format_task({"title": "Read", "priority": 2, "done": False}))print(format_task({"title": "Gym", "priority": 3, "done": True}))
What it prints
[ ] Read (p2) [x] Gym (p3)
What ✓ Check looks for
- it prints exactly:
[ ] Read (p2) [x] Gym (p3)
4.5 top_task(tasks) returns the title of the most urgent task that is not done (priority 1 is the most urgent), or None.
▶ Output
Read Line 2: IndexError: list index out of range
📦 Memory boxes
[{'title': 'Read', 'priority': 2, 'done': False}, {'title': 'Code', 'priority': 1, 'done': True}, {'title': 'Gym', 'priority': 1, 'done': False}]list🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 5 lines the student writes
def top_task(tasks): best = None for t in tasks: if not t["done"] and (best is None or t["priority"] < best["priority"]): best = t return best["title"] if best else None tasks = [{"title": "Read", "priority": 2, "done": False}, {"title": "Code", "priority": 1, "done": True}, {"title": "Gym", "priority": 1, "done": False}]print(top_task(tasks))print(top_task([]))
What it prints
Gym None
What ✓ Check looks for
- it prints exactly:
Gym None
4.6 Test your own function: write count_by_priority(tasks) returning a dictionary like {1: 2, 2: 1}, then make the asserts pass and print ok.
▶ Output
Line 5: AssertionError:
📦 Memory boxes
[{'priority': 1}, {'priority': 2}, {'priority': 1}]list🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 5 lines the student writes
def count_by_priority(tasks): counts = {} for t in tasks: p = t["priority"] counts[p] = counts.get(p, 0) + 1 return counts tasks = [{"priority": 1}, {"priority": 2}, {"priority": 1}]assert count_by_priority(tasks) == {1: 2, 2: 1}assert count_by_priority([]) == {}print("ok")
What it prints
ok
What ✓ Check looks for
- it prints exactly:
ok
Watch out
Common mistakes
Off by one
range(a, b) stops before b. Trace the first pass and the last pass.
Resetting inside the loop
total = 0 belongs before the loop, not inside it.
elif in the wrong order
The first true branch wins: put the strictest condition first.
print instead of return
A function that prints gives back None. Return the value; print it outside.
Fixing by guessing
Read the error, look at the state, change one thing.
Class activity 1 of 3
Skill check: FizzBuzz, then a twist
A classic interview warm-up, with a twist that shows whether you think about condition order.
- Print the numbers 1 to 20.
- Multiples of 3 print Fizz, multiples of 5 print Buzz.
- Multiples of both print FizzBuzz: decide where that check goes, and why.
- Twist: multiples of 7 print Bang, unless they are also a multiple of 3 or 5. Dry-run 14 and 15 to prove it.
▶ Output
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 Fizz 16 17 Fizz 19 Buzz
📦 Memory boxes
20intHint
Check 15 before 3 and 5: the first true branch wins.
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 5 lines the student writes
for n in range(1, 21): if n % 15 == 0: print("FizzBuzz") elif n % 3 == 0: print("Fizz") elif n % 5 == 0: print("Buzz") elif n % 7 == 0: print("Bang") else: print(n)
What it prints
1 2 Fizz 4 Buzz Fizz Bang 8 Fizz Buzz 11 Fizz 13 Bang FizzBuzz 16 17 Fizz 19 Buzz
What ✓ Check looks for
- it prints exactly:
1 2 Fizz 4 Buzz Fizz Bang 8 Fizz Buzz 11 Fizz 13 Bang FizzBuzz 16 17 Fizz 19 Buzz
- In the code: it uses what the lesson teaches
If they're stuck, say
Check 15 before 3 and 5: the first true branch wins.
Class activity 2 of 3
Debug the task manager
This mini task manager has three bugs. Find them from the output and the errors only: no AI, no hints for the first five minutes.
- Run it and read the first error.
- Fix one bug, run again, read the next clue.
- When it runs, compare the output line by line with the goal.
- Explain each fix in one sentence.
▶ Output
Line 10: TypeError: can only concatenate str (not "int") to str
📦 Memory boxes
[{'title': 'Read', 'done': False}, {'title': 'Code', 'done': True}, {'title': 'Gym', 'done': False}]listHint
The goal output is: Pending: 2, then 1. Read, then 2. Gym.
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 3 lines the student writes
tasks = [{"title": "Read", "done": False}, {"title": "Code", "done": True}, {"title": "Gym", "done": False}] def pending(tasks): left = [] for t in tasks: if not t["done"]: left.append(t["title"]) return left print("Pending: " + str(len(pending(tasks))))for i, title in enumerate(pending(tasks)): print(str(i + 1) + ".", title)
What it prints
Pending: 2 1. Read 2. Gym
What ✓ Check looks for
- it prints exactly:
Pending: 2 1. Read 2. Gym
- In the code: it uses what the lesson teaches
If they're stuck, say
The goal output is: Pending: 2, then 1. Read, then 2. Gym.
Class activity 3 of 3
Build it yourself: a grade report
Write it from an empty file, no AI. Plan the data and the functions first, then write.
- Use the dictionary of students and marks below.
- Write band(mark): A for 80+, B for 60+, C otherwise.
- Print every student with their mark and band, in alphabetical order.
- Print the class average to one decimal place.
▶ Output
(nothing is printed)
📦 Memory boxes
{'Zoya': 72, 'Aarush': 88, 'Mia': 55}dictHint
sorted(marks) gives the names in alphabetical order.
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 9 lines the student writes
marks = {"Zoya": 72, "Aarush": 88, "Mia": 55} def band(mark): if mark >= 80: return "A" elif mark >= 60: return "B" return "C" for name in sorted(marks): print(name, marks[name], band(marks[name]))print(f"Average: {sum(marks.values()) / len(marks):.1f}")
What it prints
Aarush 88 A Mia 55 C Zoya 72 B Average: 71.7
What ✓ Check looks for
- it prints exactly:
Aarush 88 A Mia 55 C Zoya 72 B Average: 71.7
- In the code: it uses what the lesson teaches
If they're stuck, say
sorted(marks) gives the names in alphabetical order.
After class · project
Task Manager 2.0: rebuilt by you
Rebuild the heart of your task manager from scratch, without AI: commands typed in a loop, tasks stored as a list of dictionaries, one function per job and a test for each pure function.
What to make: A command-line task manager you wrote yourself, with functions, a command loop, input checks and two tests.
Stretch: Save and load the tasks as JSON at home (json.dump and json.load), and add a 'due' date that sorts overdue tasks first.
How it is marked
| Look for | Done well when |
|---|---|
| Data | Tasks are a list of dictionaries with title, priority and done |
| Functions | Each function has one job and returns its result |
| Robust | Bad commands and bad numbers give a clear message, never a crash |
| Tests | At least two asserts for pure functions pass |
Starter code to take home
Press Copy and paste it into the editor at home, or work on it right here.
▶ Output
> Line 10: EOFError: EOF when reading a line (there is no more input; add lines to the Input box)
📦 Memory boxes
[]list🔑 Show one possible solution (try it yourself first!)
▶ Output
> Line 11: EOFError: EOF when reading a line (there is no more input; add lines to the Input box)
📦 Memory boxes
[]listHomework
Practise at home
Each one checks itself. Or print the practice sheet.
1. Trace it on paper first, then fix it: print the product of 1 to 5 (120).
▶ Output
0
📦 Memory boxes
0intn5int🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 1 line the student writes
product = 1for n in range(1, 6): product = product * nprint(product)
What it prints
120
What ✓ Check looks for
- it prints exactly:
120
2. Write count_vowels(text) and print it for 'Software Engineer' (7).
▶ Output
0
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 5 lines the student writes
def count_vowels(text): count = 0 for ch in text.lower(): if ch in "aeiou": count = count + 1 return count print(count_vowels("Software Engineer"))
What it prints
7
What ✓ Check looks for
- it prints exactly:
7
3. Fix the conditions so 0 prints zero, -4 prints negative and 9 prints positive.
▶ Output
positive negative positive
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 2 lines the student writes
def sign(n): if n == 0: return "zero" elif n > 0: return "positive" return "negative" print(sign(0), sign(-4), sign(9))
What it prints
zero negative positive
What ✓ Check looks for
- it prints exactly:
zero negative positive
4. second_largest(nums) without sort(): print it for [4, 9, 2, 9, 7] (7, because 9 is the largest).
▶ Output
9
📦 Memory boxes
🧑🏫 Model answer (for the teacher)
Teacher eyes only: hide the answers before you share your screen.
The answer green = the 7 lines the student writes
def second_largest(nums): first = second = None for n in nums: if first is None or n > first: first, second = n, first elif n != first and (second is None or n > second): second = n return second print(second_largest([4, 9, 2, 9, 7]))
What it prints
7
What ✓ Check looks for
- it prints exactly:
7
🔥 Challenge round · finished early?
The hardest questions of the lesson, no notes
Cover the notes and try these from memory. They are meant to make you think hard: draw, try small cases, and check your answer.
- Stretch task 1: Without max() or index(): print the largest number and its position, like 98 at 3.
- Stretch task 1: Nested loops: print a 3 by 4 times grid, one row per line (1 2 3 4, then 2 4 6 8, then 3 6 9 12).
- Stretch task 2: Leap years: divisible by 4, except centuries, unless divisible by 400. Print the answers for 2024, 1900, 2000 and 2023.
- Stretch task 2: A valid username is 3 to 12 characters, letters or digits only, and does not start with a digit. Check four names.
- Stretch task 3: Two bugs: it should print each task with its number (1. Read, 2. Code, 3. Sleep), then Done.
- Stretch task 3: Handle bad input: ask for an age, print Next year: N, or Please type a number if it isn't a number.
- Stretch task 4: top_task(tasks) returns the title of the most urgent task that is not done (priority 1 is the most urgent), or None.
- Stretch task 4: Test your own function: write count_by_priority(tasks) returning a dictionary like {1: 2, 2: 1}, then make the asserts pass and print ok.
🧠 Think-hard question
Write is_prime(n) without help, test it with asserts for 0, 1, 2, 9, 13 and 97, and explain why you only need to check divisors up to the square root.
Talk it through or use the drawing board. There is more than one way to get there.
Quiz · 8 questions
Final quiz: check what you learned
Pick an answer to see if it is right and why. Your best score is saved on this device.
🖨 Print what we learned
Make a worksheet from this lesson
Pick what to practise, then print it or choose Save as PDF in the print window to download it.
For parents and teachers
The 60-minute lesson plan
Use it as it is, or stretch any part over two sessions. Each row links to the part of the page you need.
| Time | Part | The teacher | The learner |
|---|---|---|---|
| 0–3 min | Warm-up | Ask for the total before anyone runs anything, then ask HOW they got it. | Predict, then explain. |
| 3–7 min | Warm-up games | Quick fire. Agree the AI rule: AI may explain, you write. | Answer and say why. |
| 7–17 min | Trace it | Do one trace table on paper together, then the dry runs with predictions. Note which predictions they miss: that's the assessment. | Trace, predict, then fix loops. |
| 17–26 min | Conditions you can prove | Make them name the boundary test values before they run anything. | Order conditions and test boundaries. |
| 26–35 min | Debug without AI | Hands off: let them read each error aloud and say the line and the type before touching code. | Read errors, fix bugs, handle bad input. |
| 35–44 min | Functions | Link every example to their own task manager. Ask: which of your functions has more than one job? | Write small functions and a test. |
| 44–49 min | FizzBuzz skill check | Time it quietly. Note how they decide the order of the checks. | FizzBuzz with a twist. |
| 49–54 min | Debug the task manager | No hints for the first five minutes. Ask them to explain each fix. | Fix three bugs. |
| 54–57 min | Grade report | Set it as homework if time is short. | Build from an empty file. |
| 57–59 min | Quiz | Predict each answer out loud first. | Answer and explain. |
| 59–60 min | Set the project | Agree the date. Ask them to bring both versions to compare. | Plan Task Manager 2.0. |
Questions to ask
- What is the state after line 3?
- Which value would you test first for this condition, and why?
- What does the error tell you: which line, which type?
- Which function in your project does more than one job?
If it feels hard
If tracing is slow, write the trace table together on paper for the first loop, then let them fill the second alone. Use 🔍 Dry run only after a prediction, never instead of one.
If it feels easy
Write is_prime(n) without help, test it with asserts for 0, 1, 2, 9, 13 and 97, and explain why you only need to check divisors up to the square root.
FAQ
Skill check: trace, predict and debug: questions
Is this course for beginners?
It is for teens who know the basics and have built something small. Lesson 1 checks exactly where you are, then the course builds strong fundamentals before algorithms, software engineering, games and AI.
Can I use AI while learning?
Yes, to explain errors and ideas, like asking a senior engineer for a hint. You write the code yourself, and you should be able to explain every line.
How long does the whole path take?
About a year at one 60-minute class a week, with small assignments between classes. You can go faster or slower; each unit ends with a project.
Start a conversation
Want a teacher to take this class?
Tell us the learner's age and level. A teacher from our network teaches with these lessons; we confirm timing and price first.
- Tell us the learner’s age or grade and goals
- We’ll suggest a suitable class or learning path
- We’ll confirm format, timing and fees with a parent or guardian