🚀 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.

Illustration of a cute pastel robot dancing
Illustration: andremsdesign / Pixabay

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.

See the teacher's plan
  1. Warm-up3 min
  2. Warm-up games4 min
  3. Trace it10 min
  4. Conditions you can prove9 min
  5. Debug without AI9 min
  6. Functions9 min
  7. FizzBuzz skill check5 min
  8. Debug the task manager5 min
  9. Grade report3 min
  10. Quiz2 min
  11. 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?

More warm-ups for every class →

🎮 Warm-up games · 5 quick games

Play with Bolt the robot

Five minutes with Bolt the robot. Vote, say why, then show the answer.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.

  1. 🔒

    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.

  2. 🔧

    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.

  3. 🛠️

    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.

Remember!
  • State = every variable's value at one moment.
  • One row per line that runs. Never skip.
  • range(a, b) stops before b.
📝 Notes

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.

Example: run it, then change it

▶ Output

10

📦 Memory boxes

total10intn4int

Fill 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.

  1. 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.

Warm-up

1.1 Fix the off-by-one so it prints the sum of 1 to 10, which is 55.

Task 1.1

▶ Output

45

📦 Memory boxes

total45intn9int
🧑‍🏫 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
Warm-up

1.2 Count how many scores are above 50 and print the count (3).

Task 1.2

▶ Output

6

📦 Memory boxes

scores[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
Core

1.3 Build the word backwards with a loop (no slicing): print CBA.

Task 1.3

▶ Output

ABC

📦 Memory boxes

word'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
Core

1.4 Use a flag: print found if any word starts with q, otherwise none.

Task 1.4

▶ Output

none

📦 Memory boxes

words['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
Stretch 🔥

1.5 Without max() or index(): print the largest number and its position, like 98 at 3.

Task 1.5

▶ Output

0 at 0

📦 Memory boxes

nums[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
Stretch 🔥

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).

Task 1.6

▶ Output


📦 Memory boxes

r3introw''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.

Remember!
  • The first true branch wins: strictest first.
  • Test below, on and above the boundary.
  • and / or stop early: use that as a guard.
📝 Notes

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.

Example: run it, then change it

▶ Output

pass

📦 Memory boxes

score95int

It 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.

  1. Puzzle 1: say what happens before you run it
  2. Puzzle 2: say what happens before you run it
  3. 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.

Warm-up

2.1 Ticket prices: under 12 pays 50, 60 or over pays 70, everyone else 100. Make price() right for 10, 30 and 65.

Task 2.1

▶ Output

50 100 100

📦 Memory boxes

No variables yet
🧑‍🏫 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
Warm-up

2.2 Fix the order of the branches so 85 gets an A (A is 80 or more, B is 60 or more).

Task 2.2

▶ Output

B B C

📦 Memory boxes

No variables yet
🧑‍🏫 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
Core

2.3 Test the boundary: print whether 12, 13 and 19 are teens (13 to 19).

Task 2.3

▶ Output

False False False

📦 Memory boxes

No variables yet
🧑‍🏫 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
Core

2.4 Guard against dividing by zero: safe_ratio(10, 0) returns 0 and safe_ratio(10, 4) returns 2.5.

Task 2.4

▶ Output

2.5
Line 2: ZeroDivisionError: division by zero

📦 Memory boxes

No variables yet
🧑‍🏫 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
Stretch 🔥

2.5 Leap years: divisible by 4, except centuries, unless divisible by 400. Print the answers for 2024, 1900, 2000 and 2023.

Task 2.5

▶ Output

True True True False

📦 Memory boxes

No variables yet
🧑‍🏫 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
Stretch 🔥

2.6 A valid username is 3 to 12 characters, letters or digits only, and does not start with a digit. Check four names.

Task 2.6

▶ Output

True
True
True
True

📦 Memory boxes

n'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.

Remember!
  • 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.
📝 Notes

'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.

Example: run it, then change it

▶ Output

90
80
70
Line 3: IndexError: list index out of range

📦 Memory boxes

scores[90, 80, 70]listi3int

Run 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.

  1. Puzzle 1: find the bug
  2. Puzzle 2: find the bug
  3. 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.

Warm-up

3.1 Fix the NameError so it prints Hello, Aarush.

Task 3.1

▶ Output

Line 2: NameError: name 'nmae' is not defined

📦 Memory boxes

name'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
Warm-up

3.2 Fix the TypeError so it prints Level: 4.

Task 3.2

▶ Output

Line 2: TypeError: can only concatenate str (not "int") to str

📦 Memory boxes

level4int
🧑‍🏫 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
Core

3.3 Fix the KeyError: print 3 for pen and 0 for pencil, without changing the dictionary.

Task 3.3

▶ Output

3
Line 3: KeyError: 'pencil'

📦 Memory boxes

stock{'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
Core

3.4 No error, wrong answer: the average of 80, 90 and 75 should be 81.67. Find the bug.

Task 3.4

▶ Output

25.0

📦 Memory boxes

marks[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
Stretch 🔥

3.5 Two bugs: it should print each task with its number (1. Read, 2. Code, 3. Sleep), then Done.

Task 3.5

▶ Output

Line 3: TypeError: unsupported operand type(s) for +: 'int' and 'str'

📦 Memory boxes

tasks['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
Stretch 🔥

3.6 Handle bad input: ask for an age, print Next year: N, or Please type a number if it isn't a number.

Task 3.6

▶ Output

Age? 14
Next year: 15

📦 Memory boxes

age14int
🧑‍🏫 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 includes Next year: 15
  • When they type fourteen, the output includes Please 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.

Remember!
  • return gives the value back; print only shows it.
  • One function, one job.
  • Pure functions can be tested with assert.
📝 Notes

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.

Example: run it, then change it

▶ Output

2 Homework

📦 Memory boxes

tasks[{'title': 'Homework', 'priority': 1}, {'title': 'Gaming', 'priority': 3}]list

Press 🔍 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.

  1. 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.

Warm-up

4.1 Write is_even(n) so it returns True or False. Print it for 4 and 7.

Task 4.1

▶ Output

True
False
None None

📦 Memory boxes

No variables yet
🧑‍🏫 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
Warm-up

4.2 average(nums) returns the mean, and 0 for an empty list. Print it for [2, 4, 9] and [].

Task 4.2

▶ Output

5.0
Line 2: ZeroDivisionError: division by zero

📦 Memory boxes

No variables yet
🧑‍🏫 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
Core

4.3 Finish add_task so it stores a dictionary with title, priority and done (False). Print the count and the last title.

Task 4.3

▶ Output

Line 7: IndexError: list index out of range

📦 Memory boxes

tasks[]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
Core

4.4 Write format_task(t) so a task prints like [ ] Read (p2), or [x] when done.

Task 4.4

▶ Output

Read
Gym

📦 Memory boxes

No variables yet
🧑‍🏫 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)
Stretch 🔥

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.

Task 4.5

▶ Output

Read
Line 2: IndexError: list index out of range

📦 Memory boxes

tasks[{'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
Stretch 🔥

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.

Task 4.6

▶ Output

Line 5: AssertionError: 

📦 Memory boxes

tasks[{'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.

  1. Print the numbers 1 to 20.
  2. Multiples of 3 print Fizz, multiples of 5 print Buzz.
  3. Multiples of both print FizzBuzz: decide where that check goes, and why.
  4. Twist: multiples of 7 print Bang, unless they are also a multiple of 3 or 5. Dry-run 14 and 15 to prove it.
Your code

▶ Output

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
Fizz
16
17
Fizz
19
Buzz

📦 Memory boxes

n20int
Hint

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.

  1. Run it and read the first error.
  2. Fix one bug, run again, read the next clue.
  3. When it runs, compare the output line by line with the goal.
  4. Explain each fix in one sentence.
Your code

▶ Output

Line 10: TypeError: can only concatenate str (not "int") to str

📦 Memory boxes

tasks[{'title': 'Read', 'done': False}, {'title': 'Code', 'done': True}, {'title': 'Gym', 'done': False}]list
Hint

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.

  1. Use the dictionary of students and marks below.
  2. Write band(mark): A for 80+, B for 60+, C otherwise.
  3. Print every student with their mark and band, in alphabetical order.
  4. Print the class average to one decimal place.
Your code

▶ Output

(nothing is printed)

📦 Memory boxes

marks{'Zoya': 72, 'Aarush': 88, 'Mia': 55}dict
Hint

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 forDone well when
DataTasks are a list of dictionaries with title, priority and done
FunctionsEach function has one job and returns its result
RobustBad commands and bad numbers give a clear message, never a crash
TestsAt 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.

Project starter

▶ Output

> Line 10: EOFError: EOF when reading a line (there is no more input; add lines to the Input box)

📦 Memory boxes

tasks[]list
🔑 Show one possible solution (try it yourself first!)
One possible solution

▶ Output

> Line 11: EOFError: EOF when reading a line (there is no more input; add lines to the Input box)

📦 Memory boxes

tasks[]list

Homework

Practise at home

Each one checks itself. Or print the practice sheet.

Warm-up

1. Trace it on paper first, then fix it: print the product of 1 to 5 (120).

Homework 1

▶ Output

0

📦 Memory boxes

product0intn5int
🧑‍🏫 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
Core

2. Write count_vowels(text) and print it for 'Software Engineer' (7).

Homework 2

▶ Output

0

📦 Memory boxes

No variables yet
🧑‍🏫 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
Core

3. Fix the conditions so 0 prints zero, -4 prints negative and 9 prints positive.

Homework 3

▶ Output

positive negative positive

📦 Memory boxes

No variables yet
🧑‍🏫 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
Stretch 🔥

4. second_largest(nums) without sort(): print it for [4, 9, 2, 9, 7] (7, because 9 is the largest).

Homework 4

▶ Output

9

📦 Memory boxes

No variables yet
🧑‍🏫 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.

🧠 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.

1What does this print?
total = 0
for n in range(1, 5):
    total = total + n
print(total)
Show the answer

10. range(1, 5) is 1, 2, 3, 4, and they add up to 10.

2What does this print?
score = 95
if score >= 50:
    print("pass")
elif score >= 90:
    print("distinction")
else:
    print("try again")
Show the answer

pass. The first true branch wins, and 95 >= 50 is checked first.

3What does this print?
x = 0
if x != 0 and 10 / x > 2:
    print("big")
else:
    print("safe")
Show the answer

safe. and stops at x != 0, so the division never runs.

4What does this print?
back = ""
for ch in "ABC":
    back = ch + back
print(back)
Show the answer

CBA. Each letter goes in front: A, then BA, then CBA.

5What does this print?
def double(n):
    n * 2

print(double(4))
Show the answer

None. double works out 8 but never returns it, so the function gives back None.

6Which error does 'Age: ' + 14 cause?
Show the answer

TypeError. Text and a number can't be added: a type problem.

7A loop gives the wrong total but no error. What do you do first?
Show the answer

Trace the state: print it or dry-run it. Look at the state, form a guess, test it.

8What does this print?
scores = [45, 72, 38, 91, 60]
count = 0
for s in scores:
    if s >= 60:
        count = count + 1
print(count)
Show the answer

3. Scores 72, 91 and 60 are 60 or more.

🖨 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.

Include
Options

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.

TimePartThe teacherThe learner
0–3 minWarm-upAsk for the total before anyone runs anything, then ask HOW they got it.Predict, then explain.
3–7 minWarm-up gamesQuick fire. Agree the AI rule: AI may explain, you write.Answer and say why.
7–17 minTrace itDo 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 minConditions you can proveMake them name the boundary test values before they run anything.Order conditions and test boundaries.
26–35 minDebug without AIHands 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 minFunctionsLink 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 minFizzBuzz skill checkTime it quietly. Note how they decide the order of the checks.FizzBuzz with a twist.
49–54 minDebug the task managerNo hints for the first five minutes. Ask them to explain each fix.Fix three bugs.
54–57 minGrade reportSet it as homework if time is short.Build from an empty file.
57–59 minQuizPredict each answer out loud first.Answer and explain.
59–60 minSet the projectAgree 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

For a child’s class, please have a parent or guardian send the enquiry. Avoid sharing passwords or sensitive personal details.

We’ll use your details only to respond to this request.

Chat on WhatsApp
Esc

Try