← ACARA Digital Technologies Years 9–10

A REPEAT…UNTIL loop with two ways to stop

A REPEAT loop whose UNTIL condition uses OR stops as soon as either part becomes TRUE, so the loop has two ways to end: a correct guess or running out of tries.

Understanding A REPEAT…UNTIL loop with two ways to stop in ACARA Digital Technologies Years 9–10

What it does: The OR in the UNTIL line gives two exits, and Tries is updated in the loop so the second exit can happen. The loop only ends when both range checks are TRUE, so a mark outside 0 to 100 is asked for again. Mark <= 100 is FALSE, so AND makes the whole condition FALSE and the loop repeats.

Common mistakes: Tries must start at 0. Starting at 5 means it becomes 6 after the first guess and never equals 5, so only a correct guess can end the loop. It should be Tries ← 0. Tries never increases, so Tries = 5 can never become TRUE. The second way to stop is lost. It should be Tries ← Tries + 1.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 492–534) and word search (Modules 459–534).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A loop ends with UNTIL Guess = Secret OR Tries = 5. The guess is wrong but Tries is 5. Does the loop stop?
Yes, Tries = 5 is TRUE, so the whole OR condition is TRUENo, the guess is still wrong, so it keeps going
Matches
UNTIL Guess = Secret AND Tries = 5
↓
AND is used instead of OR. The loop only stops if the guess is correct and the fifth try is used at the same time, so a correct guess on try 2 does not end it.
Applying
Meanings
Term
UNTIL Guess = Secret OR Tries = 5
Meaning
A REPEAT loop whose UNTIL condition uses OR stops as soon as either part becomes TRUE, so the loop has two ways to end: a correct guess or running out of tries.
Practice
Tries ← 0
Testing
Gaps
UNTIL Guess = Secret Tries = 5
Check Answer
Spots
1Tries ← 5
2REPEAT

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Warthog' badge — Definition Digger, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. A loop ends with UNTIL Guess = Secret OR Tries = 5. The guess is wrong but Tries is 5. Does the loop stop?
A. Yes, Tries = 5 is TRUE, so the whole OR condition is TRUE ✓
B. No, the guess is still wrong, so it keeps going
With OR, only one part needs to be TRUE for the loop to stop.
2. Which UNTIL line gives the guessing game two ways to stop?
A. UNTIL Guess = Secret OR Tries = 5 ✓
B. UNTIL Guess = Secret AND Tries = 5
AND would need both parts TRUE at once. OR stops the loop when either one happens.
3. In UNTIL Guess = Secret OR Tries = 5, Guess = Secret is TRUE and Tries is only 2. What happens?
A. The loop keeps repeating until Tries reaches 5
B. The loop stops, because one TRUE part is enough ✓
OR is TRUE as soon as either part is TRUE, so the correct guess ends the loop.
4. When does a REPEAT...UNTIL loop go around again?
A. While the UNTIL condition is TRUE
B. While the UNTIL condition is FALSE ✓
The loop repeats until the condition becomes TRUE, then it exits.
5. The guess is wrong and Tries = 3. What is UNTIL Guess = Secret OR Tries = 5?
A. FALSE, so the loop repeats ✓
B. TRUE, so the loop stops
Both parts are FALSE (wrong guess, and 3 is not 5), so the OR is FALSE and the loop goes round again.

Match the Pairs

UNTIL Guess = Secret OR Tries = 5 → Stop repeating as soon as the guess is correct or the player has used 5 tries, whichever happens first.
UNTIL Mark >= 0 AND Mark <= 100 → Stop repeating only when the mark is both at least 0 and at most 100, so the input is valid.
A guessing game that must stop when the guess is right or the tries have run out → REPEAT INPUT Guess Tries ← Tries + 1 UNTIL Guess = Secret OR Tries = 5
Keep asking for a mark until it is inside the valid range of 0 to 100 → REPEAT INPUT Mark UNTIL Mark >= 0 AND Mark <= 100
UNTIL Guess = Secret AND Tries = 5 → AND is used instead of OR. The loop only stops if the guess is correct and the fifth try is used at the same time, so a correct guess on try 2 does not end it.
UNTIL Mark >= 0 OR Mark <= 100 → OR is used instead of AND. Every number is at least 0 or at most 100, so the condition is always TRUE and invalid marks like 150 or -5 are accepted.

Key Term

UNTIL Guess = Secret OR Tries = 5
A REPEAT loop whose UNTIL condition uses OR stops as soon as either part becomes TRUE, so the loop has two ways to end: a correct guess or running out of tries.

Fill in the Blanks

1. REPEAT INPUT Guess UNTIL Guess = Secret OR Tries = 5
Hint: Type the logical operator that stops the loop when either reason is TRUE.
2. REPEAT INPUT Guess UNTIL Guess = Secret OR Tries = 5
Hint: Type the keyword that starts the loop's stopping condition.
3. REPEAT Tries ← Tries + 1 UNTIL Guess = Secret OR Tries = 5
Hint: Type the variable that counts how many attempts have been used.
4. REPEAT INPUT Mark UNTIL Mark >= 0 AND Mark <= 100
Hint: Type the logical operator that needs both range checks to be TRUE before the loop stops.
5. REPEAT INPUT Mark UNTIL Mark >= 0 AND Mark <= 100
Hint: Type the relational operator meaning 'greater than or equal to' for the lower limit.

Spot the Error

Question 1
A Tries ← 5
B REPEAT
C INPUT Guess
D Tries ← Tries + 1
E UNTIL Guess=Secret OR Tries=5
Line A — Tries must start at 0. Starting at 5 means it becomes 6 after the first guess and never equals 5, so only a correct guess can end the loop. It should be Tries ← 0.
Question 2
A Tries ← 0
B REPEAT
C Tries ← Tries
D INPUT Guess
E UNTIL Guess=Secret OR Tries=5
Line C — Tries never increases, so Tries = 5 can never become TRUE. The second way to stop is lost. It should be Tries ← Tries + 1.
Question 3
A REPEAT
B INPUT Mark
C UNTIL Mark>=0 OR Mark<=100
Line C — Every number is at least 0 or at most 100, so OR is always TRUE and invalid marks are accepted. Validation needs AND so both parts are TRUE before the loop stops.
Question 4
A REPEAT
B OUTPUT Mark
C UNTIL Mark>=0 AND Mark<=10
Line B — The loop never reads a new value, so Mark never changes and the UNTIL condition is never met. The line should be INPUT Mark.
Question 5
A OUTPUT "Enter a mark"
B REPEAT
C INPUT Mark
D UNTIL Mark>=0 AND Mark>=100
Line D — Mark>=100 is the wrong test for the upper limit, so only marks of 100 or more would be accepted. The second part should be Mark<=100.

Student with a class code? Join your class →