Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1REPEAT 5 TIMES SET total TO total + 2 SHOW total | ASHOW is indented inside the loop, so it prints total on every pass (5 lines) instead of once at the end. | |
| 2SET count TO 0 WHILE count < 3 SHOW count SET count TO count + 1 | BFOR each mark IN marks SET total TO total + mark SHOW total | |
| 3To print the total only once, put SHOW after the loop, lined up with REPEAT and not indented. | CThe update SET n TO n + 1 is outside the loop, so n never changes and the loop runs forever. Fix: indent it so it is inside the loop. | |
| 4A step that must happen on every pass, like adding to a total, must be indented inside the loop. | DThe update is outside the loop because it is not indented, so it never runs inside the loop and the loop never stops. | |
| 5SET total TO 0 REPEAT 4 TIMES SET total TO total + 5 SHOW total | EREPEAT 5 TIMES SET total TO total + 2 SHOW total | |
| 6SET n TO 1 REPEAT UNTIL n > 3 SHOW n SET n TO n + 1 | FSHOW is inside the loop, so it prints 5, 10, 15, 20 instead of only the final total of 20. Fix: un-indent SHOW so it is after the loop. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
loop placement error — A bug where a step sits in the wrong place around a loop. A SHOW inside repeats every pass, and an update outside runs only once. Indentation shows which steps are inside the loop.REPEAT 5 TIMES
total ← total + 2
SHOW totalREPEAT 4 TIMES
count ← count + 1
SHOW countREPEAT 3 TIMES
SHOW "Go!"
SHOW "Done"REPEAT UNTIL count = 3
count ← count + 1
SHOW countREPEAT 3 TIMES
total ← total + 5
SHOW total