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 | |
|---|---|---|
| 1WHILE Count <= 5 DO OUTPUT Count ENDWHILE | AWrong direction: Count goes up away from 0, so Count > 0 is always TRUE. Fix by using Count ← Count - 1. | |
| 2REPEAT INPUT Num UNTIL Num = 0 AND Num = 1 | BInfinite loop: Count is never changed in the body, so Count <= 5 stays TRUE forever | |
| 3Adding an update to the loop body makes the tested variable move towards the exit value, so the loop ends | CThe UNTIL condition can never be TRUE because no number is both above 100 and below 0. Fix by using OR instead of AND. | |
| 4Putting INPUT inside the loop body lets the user change the tested variable so the exit value can be reached | DInfinite loop: the UNTIL condition can never be TRUE because Num cannot be 0 and 1 at once | |
| 5Count ← 10 WHILE Count > 0 DO Count ← Count + 1 ENDWHILE | EWHILE Answer <> "Q" DO OUTPUT "Enter Q to quit" INPUT Answer ENDWHILE | |
| 6REPEAT INPUT Score UNTIL Score > 100 AND Score < 0 | FWHILE Count <= 5 DO OUTPUT Count Count ← Count + 1 ENDWHILE |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
infinite loop — A loop that never ends because nothing in the body changes the tested variable, or the condition can never reach its exit value.WHILE Count < 5 DO
Count ← Count + 1
ENDWHILEWHILE Num < 10 DO
Num ← Num + 1
ENDWHILEREPEAT
Num ← Num - 1
UNTIL Num <= 0WHILE Answer <> "yes" DO
INPUT Answer
ENDWHILEREPEAT
INPUT Guess
UNTIL Guess = 7