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 | |
|---|---|---|
| 1FOR Count ← 1 TO 10 | AFOR Number ← 1 TO 12 OUTPUT Number * 7 NEXT Number | |
| 2WHILE Password <> "open" DO | BA FOR loop is the wrong choice because the number of repeats is not known. A condition-controlled loop such as REPEAT ... UNTIL or WHILE is needed. | |
| 3A loop must run at least once, such as asking for a password before it can be checked, with the test at the end | CA count-controlled loop: use it when the number of repeats is known before the loop starts | |
| 4A scenario where the number of repeats is known: output the 12 times table | DA pre-condition loop: the test happens first, so the body may run zero times | |
| 5FOR Count ← 1 TO TotalPressed INPUT Key NEXT Count (used to keep asking until the user types STOP) | EREPEAT INPUT Password UNTIL Password = "open" | |
| 6REPEAT OUTPUT Item Count ← Count + 1 UNTIL Count > Total (Total could be 0 and nothing should print) | FREPEAT always runs at least once, so it would output an item even when Total is 0. A WHILE loop should be used because it can run zero times. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
FOR, WHILE or REPEAT — Use FOR when the number of repeats is known, WHILE when the loop may run zero times, and REPEAT when it must run at least once. WHILE tests first; REPEAT tests last.FOR Count ← 1 TO 10
OUTPUT Count
NEXT CountWHILE Stock > 0 DO
Stock ← Stock - 1
ENDWHILEREPEAT
INPUT Guess
UNTIL Guess = 7REPEAT
INPUT Guess
UNTIL Guess = SecretFOR Day ← 1 TO 7
OUTPUT Day
NEXT Day