Deciding between a decision and a repeat

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

Deciding between a decision and a repeat

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. You only take an umbrella if it is raining. Which do you use?
A REPEAT (a loop)
B IF (a decision)
2. You need to write 'Wash one plate' for all 20 plates in the sink. Which fits best?
A REPEAT 20 times
B IF there is a plate
3. Which step should go inside an IF?
A Put on a jacket only if it is cold
B Clap your hands 10 times
4. Which algorithm needs a REPEAT?
A Stir the soup until it is thick
B Wear a hat if it is sunny
5. A game checks every coin on the screen. If a coin is gold, it adds 5 points. What does it need?
A Only an IF and no REPEAT
B Both: a REPEAT with an IF inside

Match the Pairs

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

Left columnRight column
1IF it is raining THEN take an umbrella AThis claps 10 times, but the clapping was meant to happen only sometimes, such as only if the song is playing. It needs an IF.
2REPEAT 5 TIMES: jump BThe same step is written out again and again. A REPEAT 3 TIMES would do this job with one step.
3Use a decision when a step only happens sometimes, like packing a raincoat only if it is raining CA repeat: the same step happens many times, here 5 jumps.
4Use both together when a loop needs a choice inside, like checking every day of the week for rain DREPEAT 7 TIMES: IF raining THEN pack raincoat
5IF it is raining THEN take umbrella take umbrella take umbrella EA decision: the step happens only sometimes, when it is raining.
6REPEAT 10 TIMES: clap FIF raining THEN pack raincoat

Definitions

IF or REPEAT

Fill in the Blanks

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

1.
__ it is raining THEN take an umbrella
2.
______ 10 TIMES do a star jump
3.
REPEAT 5 TIMES __ the ball is red THEN put it in the red box
4.
REPEAT _____ the bowl is full pour in more water
5.
______ UNTIL the bin is empty IF the item is plastic THEN put it in recycling

Spot the Error

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

Question 1
A SET stars TO 0
B SAY Drawing stars
C IF 10 TIMES
D ADD 1 TO stars
E END REPEAT
Question 2
A ASK is it raining
B SET weather TO answer
C REPEAT UNTIL weather = rain
D TAKE umbrella
E END IF
Question 3
A SET plates TO 8
B IF plates = 8 THEN
C WASH plate
D END REPEAT
Question 4
A SET wet TO 0
B REPEAT 7 TIMES
C CHECK the sky
D REPEAT raining THEN
E ADD 1 TO wet
F END IF
Question 5
A SET pages TO 0
B REPEAT UNTIL pages = 20
C READ a page
D SET pages TO 1
E END REPEAT

Answer Key

Deciding between a decision and a repeat
Section A: Quick Questions
Q1
B — IF (a decision)
Q2
A — REPEAT 20 times
Q3
A — Put on a jacket only if it is cold
Q4
A — Stir the soup until it is thick
Q5
B — Both: a REPEAT with an IF inside
Section B: Match the Pairs
Q1
IF it is raining THEN take an umbrella → A decision: the step happens only sometimes, when it is raining.
Q2
REPEAT 5 TIMES: jump → A repeat: the same step happens many times, here 5 jumps.
Q3
Use a decision when a step only happens sometimes, like packing a raincoat only if it is raining → IF raining THEN pack raincoat
Q4
Use both together when a loop needs a choice inside, like checking every day of the week for rain → REPEAT 7 TIMES: IF raining THEN pack raincoat
Q5
IF it is raining THEN take umbrella take umbrella take umbrella → The same step is written out again and again. A REPEAT 3 TIMES would do this job with one step.
Q6
REPEAT 10 TIMES: clap → This claps 10 times, but the clapping was meant to happen only sometimes, such as only if the song is playing. It needs an IF.
Section C: Definitions
Q1
IF or REPEAT — Use IF when a step happens only sometimes. Use REPEAT when the same steps happen many times. Use both together when a loop needs a choice inside.
Section D: Fill in the Blanks
Q1
IF it is raining THEN take an umbrella
Q2
REPEAT 10 TIMES do a star jump
Q3
REPEAT 5 TIMES IF the ball is red THEN put it in the red box
Q4
REPEAT UNTIL the bowl is full pour in more water
Q5
REPEAT UNTIL the bin is empty IF the item is plastic THEN put it in recycling
Section E: Spot the Error
Q1
C — Adding a star is the same step done many times, so it needs REPEAT 10 TIMES. IF is only for a step that happens sometimes.
Q2
C — You only take an umbrella sometimes, when it is raining. That is a decision, so the line should be IF weather = rain THEN.
Q3
B — Washing a plate is the same step done many times, so it needs REPEAT 8 TIMES. An IF would only wash plates once, and only if there are 8.
Q4
D — Adding to wet should happen only on some days, when it is raining. That needs a decision, so the line should be IF raining THEN.
Q5
D — Setting pages to 1 inside the loop resets the count every time, so pages never reaches 20 and the loop never stops. It should be ADD 1 TO pages.