S3 ICT | Python Loops and Functions: Tutor Preparation Guide | for, while, range, accumulator, return
- 2026-11-12
Students can write for i in range(5), but ask them to add one to ten and they write print(1+2+3). The lesson is not about syntax; it is about one variable remembering a running total.
01 Prerequisites (3-minute check)
If any of these fails, fix it before the lesson starts.
| Skill | Quick check | Pass mark |
|---|---|---|
| Variables | After x = 5, what is x if you then write x = 7? | 7, because the later assignment wins |
| Indentation | How does Python mark lines that belong to a loop? | By indentation, usually four spaces |
| Input and output | How do print and input differ? | print writes to the screen; input reads a string from the keyboard |
02 Lesson flow (45 minutes)
| Time | Stage | Tutor does | Student does |
|---|---|---|---|
| 0-6 min | Hand first | Ask for the sum 1 to 10 by hand, write 55, then demand one program that does it | They reach 55 and see a loop is needed |
| 6-16 min | for and range | Print range(1, 11) then range(1, 12) and compare | They state the upper bound is excluded |
| 16-26 min | Three accumulator steps | Write total = 0, total = total + i, print(total) on three separate lines | A four-line program runs and prints 55 |
| 26-34 min | while and its stop test | Redo the task with while, deliberately omitting i = i + 1 | They point at the line that stops the loop |
| 34-40 min | Functions and return | Wrap the total in def add_to(n) and contrast return with print | One function with a return value written |
| 40-45 min | Exit check | Collect three answers and mark on the spot | Hand in three answers |
03 Teaching script (read it out)
Scene 1: Act 1: the upper bound of range is excluded
Stop before the bound; to include n, write n+1.
Scene 2: Act 2: reset before the loop, print after it
Reset outside, print after; a misplaced line is silently wrong.
Scene 3: Act 3: parameters are the entrance, return is the exit
Parameters in, return out; print is not return.
04 Question types and worked steps
| Type | Example | Steps | Answer |
|---|---|---|---|
| Total with a loop | Write a program that totals 1 to 10. | (1) Set total to 0 (2) for i in range(1, 11) (3) add inside the loop (4) print after it | total = 0; for i in range(1, 11): total = total + i; print(total) gives 55 |
| while and the stop test | Redo the same total with while and name the stopping condition. | (1) Set i to 1 and total to 0 (2) while i <= 10 (3) add and increment i (4) print | The stop test is i <= 10; without i = i + 1 the loop never ends |
| Accumulator placement | This prints only 10: for i in range(1, 11): total = 0; total = total + i. Why? | (1) Find where total is set (2) check whether it is indented (3) move it out (4) run again | The reset sits inside the loop and clears the total each pass; outside, it prints 55 |
| Functions and return | Write a function returning the sum of even numbers from 2 to 10. | (1) Define it with a parameter (2) set total to 0 (3) loop range(2, 11, 2) adding (4) return total and print outside | def even_sum(): total = 0; for n in range(2, 11, 2): total += n; return total gives 30 |
05 Independent practice (3 questions)
| Question | Answer | What to watch |
|---|---|---|
| Print the odd numbers from 1 to 20 with one for loop. | for i in range(1, 21, 2): print(i) | Start at 1 with a step of 2 |
| Write a function returning the average of 62, 78 and 85. | def average(a, b, c): return (a + b + c) / 3, which gives 75.0 | Return, then print outside |
| Why must a while loop be handled carefully? Give one failure. | If the stop test never becomes false, the loop runs forever, for example when i = i + 1 is missing | Write the stop test first |
06 Common mistakes and what to say
| Mistake | Student writes | Say this |
|---|---|---|
| A range one short | “range(1, 10) covers 1 to 10.” | “range stops before its upper bound, so that is 1 to 9 and the total is 45. Write 11 to get 55.” |
| The accumulator reset inside the loop | “Putting total equals 0 in the loop is tidier.” | “Each pass clears it, so only the last value survives and you print 10. Reset before the loop and print after.” |
| Treating print as return | “My function prints, so the value is available outside.” | “print only displays; the call still returns None. Use return, then print the result at the call site.” |
| Inconsistent indentation | “Indentation is just formatting.” | “Python uses indentation to decide which lines belong to the loop, and mixing tabs with spaces raises IndentationError. Four spaces per level.” |
07 Homework (paper, section and question numbers)
- Chapter practice: total 1 to 100 with a for loop, then verify with the formula — Python chapter, practice question 1
- Chapter practice: wrap the total in a function and test with 10, 100 and 1,000 — Python chapter, practice question 2
- Extension: use nested loops to print a rectangle three rows by four stars and count the stars — Python chapter, practice question 3
08 Exit check (last 5 minutes)
| Question | Answer | Decision |
|---|---|---|
| Does range(1, 11) include 11? | No, it covers 1 to 10 | Wrong means reteach Act 1 |
| Why reset the accumulator before the loop? | Resetting inside clears it each pass, leaving only the last value | Wrong means reteach Act 2 |
| What separates return from print? | return hands the value back to the caller; print only displays it | Confusion means Act 3 again |
09 Tutor FAQ
Should list comprehensions be taught?
Not in S3. Get the four-line loop right first; the shorthand belongs to senior years.
Is while True with break acceptable?
It runs, but discourage it. Marks come from a clear stop test, which while True tends to hide.
Is exception handling needed?
Not here. Bad input belongs to the file and data handling chapter; secure loops and functions first.
Find a tutor — freeTutor Registration →
A TutorZone lesson-prep guide. Written by the TutorZone team; questions and lesson flow are original and are not taken from any school or publisher material.


