/en-tutor-prep-s5-ict-programming-python-loops/
/en-tutor-prep-s5-ict-programming-python-loops/
英文版
3
General Inquiry: info@TutorZone.com.hk
Office Hours: Monday to Saturday - 9:00 AM to 6:00 PM
WhatsApp Monday to Sunday - 24 hours
Hotline: +852 6828 1809
Instant Support: +852 9061 3106

DSE ICT | Python loops and conditions: a tutor preparation guide (trace tables, three question types, four errors)

DSE ICT | Python loops and conditions: a tutor preparation guide (trace tables, three question types, four errors)

  • 2026-11-10

Students can write for i in range(5) but guess when asked what i holds after the loop. The gap is not syntax; they have never written execution down. This lesson does one thing: it makes the trace table the first move on every question, so a loop becomes a visible process rather than a memorised line.

Objectives — Students can: (1) state the start, the stop boundary and the number of iterations from the three range arguments; (2) fill a trace table line by line and report what every variable holds after the loop; (3) choose between for and while and write the exit condition plus a zero-iteration boundary test.

01 Prerequisites (3-minute check)

If any of these fails, fix it before the lesson starts.

Skill Quick check Pass mark
Variables After x = 3 then x = x + 2, what is x 5: assignment overwrites, it does not add
Operators What are 10 % 3 and 10 // 3 1 and 3: remainder and floor division
Indentation What marks the body of a Python loop The indent level, not braces

02 Lesson flow (60 minutes)

Time Stage Tutor does Student does
0-6 min Three opening questions Show a three-line loop; ask how many times it runs and what i ends at Commit an answer, check it later
6-18 min range in three parts Change start, stop and step one at a time; students call out counts Say the count aloud, then code it
18-32 min Trace table Model recording i, total and the condition on every line Fill the same table themselves
32-44 min while and exit Rewrite the same job with while; show when the condition turns false Rewrite and add a zero-iteration test
44-56 min Three question types Walk one output, one fill-in and one debugging question Do one alone and self-mark
56-60 min Exit check Collect two questions; mark which boundary or state was lost Work independently

03 Teaching script (read it out)

Scene 1: range is a walk between boundaries, not a count of turns

Students read range(5) as “do it five times” and then read range(1, 5) the same way; the moment a step appears, everything collapses. Teach it as three parts: start, stop (exclusive), step. Write range(a, b, s) and make them say the sentence: begin at a, keep adding s, stop when the value is no longer smaller than b. Only then count. Then contrast three cases: range(1, 6) and range(6) print the same thing but have different boundaries; range(5, 0, -1) counts down; range(0, 10, 3) runs four times. Every count is checked with (b – a + s – 1) // s, so arithmetic replaces memory.

Students do: fill a four-cell row (start, stop, step, count) for three ranges, then run them to confirm.

Scene 2: The trace table: one line at a time, no skipping

Asked what total holds after a loop, students run it in their heads and lose track by the third turn. Fix the format: line number, the value of every variable after that line, and the result of the test. Read the code aloud, never the result; the students fill the table, and only then do you compare answers. When an if sits inside the loop, both branches must appear, because a missing branch is a missing pass. The table also turns “how many lines are printed” into a visible count: the number of printing rows is the answer.

Students do: build a six-row table for total = 0 followed by for i in range(1, 6): total = total + i, then state the final total.

Scene 3: while: write the stopping condition before the body

Almost every while error is a condition that never becomes false, not a syntax error. Reverse the order: on paper first write when to stop as a testable condition, then the body, then the update statement. The update must sit inside the loop and must move the condition towards false; students should point to that line out loud. Then add two boundary tests: the condition false at the start (zero iterations) and true for exactly one iteration. The zero case is missed most often because students assume a loop always runs once. Finish with the rule: known count means for, unknown count or wait-for-a-state means while.

Students do: write the skeleton of a while loop that reads numbers until 0 is entered, and say when the zero-iteration case occurs.

04 Question types and worked steps

Type Example Steps Answer
Output question State the printed output Fill the trace table, then copy its printing rows Number of answers must equal the printing rows
Fill in the blank Complete the range arguments Work backwards from the count with (b – a + s – 1) // s Substitute back and check the count
Debugging The loop hangs or gives a wrong result Find the update, then the indent, then the direction of the test Name why the single change fixes it
State question Value of a variable after the loop Run the table to the last row and read that column The answer must match the table
Sanity check (teach this): Only one tool is used all lesson, the trace table, because the missing skill is recording execution rather than syntax knowledge. Every range is verified by arithmetic so nothing depends on memory. The zero-iteration boundary is taught explicitly because that is where examination marks disappear. The tutor reads code and never the answer, which forces students to execute it themselves.

05 Independent practice (3 questions)

Question Answer What to watch
Boundary row Start, stop, step and count for three ranges Check whether range(5, 0, -1) is counted as six
Trace table Fill a table for a six-line loop with an if Check whether the condition column is missing
while rewrite Convert the for version and state the zero case Check that the update is inside the loop

06 Common mistakes and what to say

Mistake Student writes Say this
Treating the stop value as included Reading range(1, 5) as five turns “Where does the walk stop? Count it out: 1, 2, 3, 4. Where would a fifth come from?”
Skipping rows in the table Recording total but not i, so the answer drifts “You did not record i. What was added on the second pass? Add that row back.”
No update in while The loop never ends “Which line makes this condition false one day? If you cannot find it inside the loop, it is an infinite loop.”
Assuming at least one pass Answering one iteration when the condition is false at the start “The condition is already false before entry. Which line inside could run? Zero.”

07 Homework (paper, section and question numbers)

08 Exit check (last 5 minutes)

Question Answer Decision
Three parts of range Start, stop (exclusive), step Missing one sends you back to act one
Three trace columns Line, variable values, test result Cannot name them sends you back to act two
while exit Write the stop condition, then the in-loop update “It depends” sends you back to act three

09 Tutor FAQ

Must students memorise the count formula?

No, but they must check with arithmetic; keep it on the board and have them substitute once per question.

Should other languages be taught?

DSE ICT tests concepts, and pseudocode needs the same trace table; one minute on syntax differences is enough.

Which loop comes first for weak students?

for, because the count is known and the boundary is visible; add while only when for is secure.

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.

Join as a tutor or coach — academic, music, sports, arts, STEM. Free to register. See how it works →