Junior Secondary ICT (S2) — Programming Basics Lesson-Prep Guide | Variables, Conditions and Loop Tracing
- 2026-11-21
Students can read a program but fall apart when asked to trace the output line by line. This lesson does three things only: variables as named boxes, conditions as forks in a road, loops as repeated copying, with a trace table for every step.
01 Prerequisites (3-minute check)
If any of these fails, fix it before the lesson starts.
| Skill | Quick check | Pass mark |
|---|---|---|
| Order of operations | What is 2 plus 3 times 4? | 14 |
| Averages | What is the mean of 12, 15, 9 and 18? | 13.5 |
| Comparison | If 60 is a pass, does 55 pass? | No |
02 Lesson flow (60 minutes)
| Time | Stage | Tutor does | Student does |
|---|---|---|---|
| 0–5 min | Prior-knowledge check | Ask what a variable is and write the answers up | Write a one-sentence definition |
| 5–20 min | Act one: variables and types | Model assignment and reassignment; show that numbers and strings do not add directly | Copy three assignments and write the value after each |
| 20–35 min | Act two: conditions | Draw the fork, then run a pass and a fail case | Write the branch result for two scores |
| 35–45 min | Act three: loops | Model for and while, filling a trace table | Trace a four-iteration loop alone |
| 45–55 min | Three independent questions | Read only, no hints | Solve all three with a trace table each |
| 55–60 min | Exit check | Read three questions and collect answers | Write answers |
03 Teaching script (read it out)
Scene 1: A variable is a box with a name on it
Ask why swapping two values needs a third temporary variable.
Scene 2: A condition is a fork, not arithmetic
Ask which branch a score of 60 takes, and why the test is not greater-than.
Scene 3: A loop is repeated copying, so count the iterations
Ask for the value left in the variable when the while loop stops.
04 Question types and worked steps
| Type | Example | Steps | Answer |
|---|---|---|---|
| Predict the output | The total of 1 to 5 | Fill a trace table rather than guessing | 15 |
| Branch on a condition | What do scores 55 and 72 print? | Test the condition first, then write the branch | Fail and pass |
| Count iterations | Multiplying by 3 until above 50: how many times? | List the intermediate values, then count | Four times, final value 81 |
| Debug | A loop prints four times instead of five | Check the upper bound of the range | The bound is 4 and should be 5 |
05 Independent practice (3 questions)
| Question | Answer | What to watch |
|---|---|---|
| Write the sum of the even numbers from 2 to 10 | 30, from 2, 4, 6, 8 and 10 | Did they list the five values? |
| Convert 25 degrees Celsius to Fahrenheit | 77 degrees | Did they multiply by 9, divide by 5, then add 32? |
| A loop starts at 1 and multiplies by 3 while the value is less than 50. What is the final value? | 81 | Did they write 1, 3, 9, 27 and 81? |
06 Common mistakes and what to say
| Mistake | Student writes | Say this |
|---|---|---|
| Treating a variable as a constant | First equals 5, and later changes are ignored | A variable changes, so after every line ask what its value is now and write it in the trace table. |
| Using greater-than instead of not-less-than | A score of 60 is marked as a fail | 60 passes, so the test must be not-less-than; always run the boundary value once. |
| Off-by-one in a range | A loop should run five times but runs four | The upper bound is the number of passes, not the last value; count the intermediate values after writing it. |
| Inconsistent indentation | One block is indented four spaces and another two | Statements on the same level line up; wrong indentation sends the program down the wrong branch or raises an error. |
07 Homework (paper, section and question numbers)
- Redo practice question 1 for the odd numbers from 3 to 9 — List the values, then write the total
- Redo practice question 3 with the limit raised to 100 — Show each value and count the multiplications
- From the ICT chapter index, copy one condition and label both branches — Mark which line belongs to which branch
08 Exit check (last 5 minutes)
| Question | Answer | Decision |
|---|---|---|
| How does a variable differ from an unknown in algebra? | A variable can be reassigned, so its value changes | An answer of they are the same means assignment needs reteaching |
| What does a score of 60 print under a not-less-than 60 test? | Pass | An answer of fail means the boundary was missed |
| Starting at 1 and multiplying by 3 while the value stays less than 50: how many multiplications? | Four | Three means the final pass was dropped |
09 Tutor FAQ
Can this be taught before students know any programming language?
Yes. The lesson uses pseudocode and trace tables, with syntax kept minimal; sequence, selection and repetition transfer to any language.
Should functions be introduced straight away?
No. S2 students should first master variables, conditions and loops and trace output themselves; functions come once they can debug alone.
What if a student copies code correctly but cannot explain it?
Ask them to close the screen and re-run the same program aloud with a trace table; if they cannot narrate it, reteach that section.
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.



