REPEAT UNTIL a condition is true

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

REPEAT UNTIL a condition is true

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which loop stops when the condition becomes TRUE?
A REPEAT 5 TIMES
B REPEAT ... UNTIL
2. You are filling a bucket and don't know how many scoops it will take. Which loop fits best?
A REPEAT add a scoop UNTIL bucket is full
B REPEAT 10 TIMES add a scoop
3. What is the stopping condition in this loop? REPEAT walk forward UNTIL you reach the wall
A walk forward
B you reach the wall
4. REPEAT knock on door UNTIL someone answers. When does the knocking stop?
A When someone answers
B After knocking 3 times
5. Which loop will never stop? Both start with the counter at 1 and the step is 'say hello'.
A REPEAT say hello UNTIL 1 is equal to 2
B REPEAT say hello UNTIL 1 is equal to 1

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1REPEAT Add 1 cup of water UNTIL bucket is full AThe stopping condition is missing after UNTIL, so the computer doesn't know when to stop repeating.
2UNTIL password is correct BREPEAT Eat one bite UNTIL plate is empty
3Use REPEAT UNTIL when you don't know in advance how many times the steps must run CKeep adding water again and again until the bucket is full, even if we don't know how many cups it takes
4A loop must change something inside it so the stopping condition can become true DREPEAT Roll the dice UNTIL the dice shows 6
5REPEAT Walk 1 step UNTIL I have wings EThe stopping condition: the loop ends when this becomes true
6REPEAT Clap your hands UNTIL FThe condition can never become true, because walking will never give you wings. The loop never stops.

Definitions

REPEAT ... UNTIL

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
______ Kick the ball UNTIL the goal is scored
2.
REPEAT Stir the soup _____ the soup is hot
3.
REPEAT Add 1 to steps UNTIL steps _ 10
4.
REPEAT Add 1 to _____ UNTIL score = 10
5.
REPEAT ___ 1 to count UNTIL count = 3

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A REPEAT
B ASK for the password
C READ the answer
D UNTIL answer is wrong
Question 2
A SET score TO 0
B REPEAT
C ADD 1 TO score
D UNTIL score < 0
Question 3
A REPEAT
B Throw the dice
C IF you roll a 6
Question 4
A UNTIL
B Stir the soup
C Taste the soup
D UNTIL it tastes good
Question 5
A SET energy TO -3
B REPEAT
C Run one lap
D SUBTRACT 1 FROM energy
E UNTIL energy = 0

Answer Key

REPEAT UNTIL a condition is true
Section A: Quick Questions
Q1
B — REPEAT ... UNTIL
Q2
A — REPEAT add a scoop UNTIL bucket is full
Q3
B — you reach the wall
Q4
A — When someone answers
Q5
A — REPEAT say hello UNTIL 1 is equal to 2
Section B: Match the Pairs
Q1
REPEAT Add 1 cup of water UNTIL bucket is full → Keep adding water again and again until the bucket is full, even if we don't know how many cups it takes
Q2
UNTIL password is correct → The stopping condition: the loop ends when this becomes true
Q3
Use REPEAT UNTIL when you don't know in advance how many times the steps must run → REPEAT Roll the dice UNTIL the dice shows 6
Q4
A loop must change something inside it so the stopping condition can become true → REPEAT Eat one bite UNTIL plate is empty
Q5
REPEAT Walk 1 step UNTIL I have wings → The condition can never become true, because walking will never give you wings. The loop never stops.
Q6
REPEAT Clap your hands UNTIL → The stopping condition is missing after UNTIL, so the computer doesn't know when to stop repeating.
Section C: Definitions
Q1
REPEAT ... UNTIL — A loop that keeps repeating its steps until a condition becomes true. Use it when you don't know how many times. Make sure the condition can happen, or the loop never stops.
Section D: Fill in the Blanks
Q1
REPEAT Kick the ball UNTIL the goal is scored
Q2
REPEAT Stir the soup UNTIL the soup is hot
Q3
REPEAT Add 1 to steps UNTIL steps = 10
Q4
REPEAT Add 1 to score UNTIL score = 10
Q5
REPEAT Add 1 to count UNTIL count = 3
Section E: Spot the Error
Q1
D — The loop would stop on a wrong answer. It should keep asking until the answer is correct, so the line should be UNTIL answer is correct.
Q2
D — The score starts at 0 and goes up, so it can never be less than 0. The loop would never stop. It should be UNTIL score = 10.
Q3
C — A REPEAT loop must end with UNTIL and the stopping condition. IF belongs to branching. It should be UNTIL you roll a 6.
Q4
A — A REPEAT ... UNTIL loop must start with REPEAT. UNTIL goes at the end with the condition. Line 1 should be REPEAT.
Q5
A — Energy starts below 0 and keeps going down, so it never equals 0. The loop would never stop. It should start at a positive number such as SET energy TO 10.