VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

PG2 G2 Computing Scratch Loops and Conditions: Why Does My Child’s Game Never Stop?

A PG2 student may build a Scratch game in which a character moves correctly at first but repeats forever, skips an instruction or stops before the score reaches its target. The problem is often in the difference between a fixed-count loop, an endless loop and a condition-based loop. A working program needs a clear starting state, a rule that updates the relevant variable and a condition that can eventually become true.

Parents can help without doing the coding. Ask what the program should do, what changes in each repetition and what must happen for it to finish. Trace the program on paper before modifying one Scratch block. The 2027 SEC G2 Computing syllabus K237 covers flowchart interpretation, variables, conditional instructions, basic and conditional loops, and debugging. It is an optional examined subject where schools offer it, not a compulsory subject for every PG2 pupil.

  • State the expected behaviour before running the program.
  • Identify where the score, counter or other variable is initialised.
  • Distinguish repeat, forever and repeat-until loops.
  • Check that the loop body actually changes the stopping condition.
  • Test boundary cases such as just below, exactly at and just above a target.
  • Follow the school’s permitted Scratch tasks and eventual Computing K237 requirements.

Why a forever loop behaves as its name suggests

A forever block repeatedly executes its contents until the script or project is otherwise stopped. This can be appropriate for continuously checking a game’s controls, but it is not suitable as a self-terminating counter unless other instructions explicitly stop execution. A child might place a “move 10 steps” block inside forever and then wonder why the character keeps moving.

Ask the student whether the instruction is intended to run continuously or stop after a number of steps. If the desired task is “move five times”, a fixed-count repeat may be more appropriate. If it is “continue until the score reaches five”, a condition-based loop is often a better starting point.

Repeat and repeat-until have different stopping rules

A repeat block executes its body a specified number of times. A repeat-until block checks a condition and repeats while that condition is false, ending when it becomes true. In an introductory Scratch example, initialise score to zero, then repeat until score = 5, changing score by one each iteration.

The child should trace the values: 0, 1, 2, 3, 4, 5. At five the condition is satisfied, so repetition stops. Ask how the outcome changes if the initial score is not zero or if the update changes by two instead of one. A stopping rule must match the steps used to reach it.

A condition that never becomes true creates a trap

Suppose a loop repeats until score = 5 but the score starts at zero and changes by two each time. It becomes 2, 4, 6, 8 and so on, never exactly five. The program may therefore keep running even though the value has passed the intended threshold.

An appropriate check may be score >= 5 when the task means “stop once the target is reached or exceeded”. This example teaches the difference between equality and a threshold. The exact operator available and its meaning should match the school’s software and task.

Variables need a clear starting state

If score is not reset when the green flag is clicked, a new run may begin from a leftover value. In a simple game, a score that previously ended at five could cause a repeat-until condition to be satisfied immediately on the next run. The program appears to stop too early because the starting conditions were not restored.

Ask the student where score is created, where it is initialised and which instructions update it. A trace table with columns “step”, “score before” and “score after” can expose the problem more clearly than repeatedly rearranging blocks.

If and if-else choose what happens

An if block executes a set of instructions when the stated condition is true. An if-else block chooses between two alternatives based on whether the condition is true or false. These are decisions, not automatically loops. When placed inside a loop, the same decision can be evaluated repeatedly.

For an example, if a character touches a target, increase the score; otherwise it continues moving. The child should say when the condition is tested and what happens in each branch. If the condition is evaluated only once before the game starts, the behaviour may differ from a condition checked continuously during play.

AND, OR and NOT do not mean the same thing

A combined condition with AND requires both conditions to be true; OR requires at least one; NOT reverses the truth of a condition. A game might need to stop when the player has enough points OR when time runs out. Using AND instead could make the program wait for both events, which may not be possible at the same time.

Ask the student to test the condition under four simple scenarios. This can be done on paper without running code. A truth table helps them predict the intended behaviour and avoids trial-and-error changes that create new bugs.

Flowcharts help explain the logic

A basic flowchart can show the program’s starting point, a sequence of actions, a decision and a return arrow for repetition. The 2027 K237 syllabus expects candidates to interpret flowcharts to understand the sequence of events. Parents can ask the child to convert a tiny Scratch script into ordinary-language steps, then sketch its decision structure if the teacher has introduced that skill.

Do not require advanced pseudocode notation simply because other Computing syllabuses use it. The learning target is understanding what executes next and why. Match the teacher’s notation and flowchart conventions.

Why an off-by-one error happens

A common mistake is updating a counter before checking a threshold or after displaying a result, causing one extra or one missing iteration. For example, if a loop should display the numbers 1 to 5 but first increases a variable already set to one, it may begin by showing two.

Trace the first and last iterations explicitly. Ask whether the first action happens before or after the counter changes. A child who can describe the order of operations can solve many off-by-one errors without memorising a special fix.

Use predictable tests before building a whole game

Start with a script that counts a few steps, changes one variable and stops. Then test starting values below, at and above the target. Only after it works should the child add sprites, backdrops, sounds or more complex conditions. This keeps the original bug from being hidden under extra features.

A parent should not build the project or copy a complete online game in place of the student’s work. The purpose is for the student to understand each decision and be able to correct a new problem independently.

Scratch and the 2027 G2 SEC syllabus

The 2027 G2 Computing K237 syllabus includes interpretation of flowcharts, if/if-else decisions with limited nesting, basic loops (repeat, forever and for), conditional loops (repeat-until and while), logical operators and program debugging. Paper 1 is an e-examination; Paper 2 is a lab-based paper assessing spreadsheets, media software and programming. Scratch blocks are listed for Papers 1 and 2, while specified MakeCode microcontroller material is assessed in Paper 1 only.

This is the examined-subject specification for the 2027 cohort. A PG2 Secondary 1 student may currently be taking common curriculum or coding CCA activities instead, and Computing K237 availability varies by school. Ask the school which subject and software the child actually has.

A ten-minute parent debugging exercise

Write a desired outcome: “Count from zero and stop when the value reaches at least five.” Have the child predict the output for a fixed-count repeat, a forever block and a repeat-until condition. Then trace the values and locate the rule that should stop repetition. Make only one program change and test again.

For wider debugging habits, see our PG2 guide to finding bugs in Computing. If the program behaves differently from the child’s explanation, bring the short script and test results to the teacher. A correct test is better evidence of learning than a polished game copied from a tutorial.

Questions parents often ask

Does a repeat-until loop always end?

No. It only ends when its stopping condition becomes true; a condition that is never reached can cause continuous repetition.

Is an if block a loop?

No. It is a conditional decision. It can be placed inside a loop so that it is evaluated repeatedly.

Must G2 Computing students learn Python?

Do not assume so. The 2027 K237 examined programming outcomes and practical resources specify visual programming tools; follow the school’s current course and software.

Official syllabus and next steps

Official curriculum sources: MOE Full Subject-Based Banding, SEAB Singapore-Cambridge SEC overview and the official 2027 G2 school-candidate syllabus listing. These documents describe the 2027 examination cohort, not the complete lesson sequence for a child entering Secondary 1 in 2027. Confirm the student’s present subject level, teacher’s instructions, syllabus year and any elective availability with the school.

Choose one marked school question or practical task, identify the first step your child cannot explain and practise that skill with one new example. Review whether the child can work independently before adding more worksheets or tuition hours. If the error recurs, show the marked work to the subject teacher. A posting group, one test result or a past school cut-off point does not define the child’s capacity to learn.