← ACARA Digital Technologies Years 9–10

Designing an algorithm that uses logical operators with selection and iteration

A complete design where a loop repeats, IF decisions use AND, OR or NOT, and the flowchart and the pseudocode do the same job, so both versions agree.

Understanding Designing an algorithm that uses logical operators with selection and iteration in ACARA Digital Technologies Years 9–10

What it does: AND needs both parts true, so the child price applies only to under-16s on a day that is not Saturday. Checking both versions agree means the loop, decision and OR condition in the flowchart match the pseudocode exactly. The game keeps running only while neither stop rule has happened. Flipping OR to AND and reversing each test gives the continue condition. NOT loggedIn is true while the login has not yet succeeded. Without NOT, the loop would never start for a user who is not logged in. A decision inside the loop body is checked on every repeat. Placed after ENDWHILE, it would only price one customer.

Common mistakes: The game should start with 3 lives. With life ← 0 the condition life > 0 is false straight away, so the WHILE loop never runs. It should be life ← 3. A single = compares two values; it does not store one. To set the discount price the line must use the assignment arrow: price ← 8.

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 login allows 3 attempts. Which loop condition keeps asking while the password is wrong AND attempts are left?
WHILE password <> correct AND attempts < 3 DOWHILE password <> correct OR attempts < 3 DO
Matches
WHILE attempts < 3 OR NOT loggedIn DO
↓
OR keeps the loop running while attempts are under 3, even after a successful login, or while not logged in, even after 3 failures. It should be AND so both conditions must hold.
Applying
Meanings
Term
WHILE + IF + AND/OR/NOT
Meaning
A complete design where a loop repeats, IF decisions use AND, OR or NOT, and the flowchart and the pseudocode do the same job, so both versions agree.
Practice
attempts ← 0
Testing
Gaps
WHILE attempts < 3 correct = FALSE DO
Check Answer
Spots
1life ← 0
2pts ← 0

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

The 'Desert Tortoise' badge — Desert Master, 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 login allows 3 attempts. Which loop condition keeps asking while the password is wrong AND attempts are left?
A. WHILE password <> correct AND attempts < 3 DO ✓
B. WHILE password <> correct OR attempts < 3 DO
The loop should only continue when BOTH parts are true. With OR, the loop would keep going after 3 attempts if the password was still wrong.
2. A game ends when lives = 0 OR score = 10. Which WHILE condition keeps the game running?
A. WHILE lives > 0 AND score < 10 DO ✓
B. WHILE lives > 0 OR score < 10 DO
The game keeps running only while neither stop rule has happened. Flipping OR to AND and reversing each test gives the continue condition.
3. The same game uses REPEAT...UNTIL. Which line stops the loop correctly?
A. UNTIL lives = 0 AND score = 10
B. UNTIL lives = 0 OR score = 10 ✓
The game must stop when EITHER rule is met. AND would make the player wait until they had no lives and a perfect score at the same time.
4. Tickets cost $8 for children under 13 or adults 65 and over. Which IF is correct?
A. IF age < 13 AND age >= 65 THEN
B. IF age < 13 OR age >= 65 THEN ✓
No one is both under 13 and 65 or older, so the AND condition is never true. OR lets either group get the cheaper price.
5. A login loop should run while the user is NOT logged in and has attempts left. Which is correct?
A. WHILE NOT loggedIn AND attempts < 3 DO ✓
B. WHILE loggedIn AND attempts < 3 DO
NOT loggedIn is true while the login has not yet succeeded. Without NOT, the loop would never start for a user who is not logged in.

Match the Pairs

WHILE attempts < 3 AND NOT loggedIn DO → The login loop keeps running only while the user has tries left and has not yet logged in. It stops on either event.
UNTIL lives = 0 OR score = 10 → The game loop stops as soon as either the player runs out of lives or reaches a score of 10.
A ticket price decision uses AND so the child price only applies on a weekday when the person is under 16 → IF age < 16 AND day <> "Saturday" THEN price ← 8
The flowchart and the pseudocode agree when both show the same loop, the same decision and the same AND/OR condition → REPEAT ... IF lives = 0 OR score = 10 THEN stop
WHILE attempts < 3 OR NOT loggedIn DO → OR keeps the loop running while attempts are under 3, even after a successful login, or while not logged in, even after 3 failures. It should be AND so both conditions must hold.
IF lives = 0 AND score = 10 THEN OUTPUT "Game over" → AND needs both to be true at once, so the game would not end when only lives = 0 or only score = 10. It should use OR.

Key Term

WHILE + IF + AND/OR/NOT
A complete design where a loop repeats, IF decisions use AND, OR or NOT, and the flowchart and the pseudocode do the same job, so both versions agree.

Fill in the Blanks

1. attempts ← 0 WHILE attempts < 3 AND correct = FALSE DO attempts ← attempts + 1
Hint: Type the logical operator that keeps the login loop running only while both conditions are true.
2. IF age < 13 OR age > 64 THEN price ← 8 ENDIF
Hint: Type the logical operator that gives the cheaper price when either age condition is true.
3. REPEAT score ← score + 1 UNTIL lives = 0 OR score = 10
Hint: Type the keyword that ends a post-condition loop and introduces the condition that stops the game.
4. IF age < 18 AND NOT (day = "Sat") THEN price ← 10 ENDIF
Hint: Type the logical operator that reverses the day check so Saturday is excluded.
5. WHILE lives > 0 AND score < 10 DO score ← score + 1 ENDWHILE
Hint: Type the keyword that closes the loop, matching the flowchart arrow that returns to the decision.

Spot the Error

Question 1
A life ← 0
B pts ← 0
C WHILE life > 0 AND pts < 10 DO
D IF hit THEN life ← life - 1
E IF gem THEN pts ← pts + 1
F ENDWHILE
Line A — The game should start with 3 lives. With life ← 0 the condition life > 0 is false straight away, so the WHILE loop never runs. It should be life ← 3.
Question 2
A INPUT age, isTue
B price ← 15
C IF age < 13 OR isTue THEN
D price = 8
E ENDIF
F OUTPUT price
Line D — A single = compares two values; it does not store one. To set the discount price the line must use the assignment arrow: price ← 8.
Question 3
A n ← 0
B INPUT pw
C WHILE pw <> 1234 OR n < 3 DO
D n ← n + 1
E INPUT pw
F ENDWHILE
Line C — The loop must stop when the password is right OR the attempts run out, so it keeps going only while BOTH pw is wrong AND n < 3. With OR, a wrong password keeps the loop running after 3 tries. It should be AND.
Question 4
A INPUT age
B WHILE age < 0 AND age > 120 DO
C OUTPUT 'Try again'
D INPUT age
E ENDWHILE
Line B — No number can be below 0 and above 120 at the same time, so AND is always false and invalid ages are never re-asked. An invalid age is too low OR too high, so it should be OR.
Question 5
A life ← 3
B pts ← 0
C REPEAT
D IF hit THEN life ← life + 1
E IF gem THEN pts ← pts + 1
F UNTIL life = 0 OR pts = 10
Line D — Being hit should cost a life, so life must go down. Adding 1 means life never reaches 0 and the game cannot end that way. It should be life ← life - 1.

Student with a class code? Join your class →