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 Row <- 1 TO 3 FOR Col <- 1 TO 4 OUTPUT Row * Col NEXT Col NEXT Row | AFOR Player <- 1 TO 5 WHILE Score < 10 DO Score <- Score + 1 ENDWHILE NEXT Player | |
| 2NEXT Col NEXT Row | BThe inner and outer loops use the same counter name A, so the inner loop changes the outer counter. Use different names such as A and B. | |
| 3The inner loop restarts and completes all its repeats every time the outer loop repeats once | CA FOR loop inside a FOR loop: the inner body runs 3 x 4 = 12 times in total | |
| 4A WHILE loop can be nested inside a FOR loop, and the WHILE loop finishes before the next FOR repeat | DCloses the inner loop first, then closes the outer loop | |
| 5FOR A <- 1 TO 3 FOR A <- 1 TO 2 OUTPUT A NEXT A NEXT A | EThe NEXT statements are in the wrong order. The inner loop must end first: NEXT Y then NEXT X. | |
| 6FOR X <- 1 TO 3 FOR Y <- 1 TO 2 OUTPUT X, Y NEXT X NEXT Y | FFOR Day <- 1 TO 2 FOR Lap <- 1 TO 3 OUTPUT Day, Lap NEXT Lap NEXT Day |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
nested loop — A loop placed inside another loop. The inner loop completes all its repeats for every single repeat of the outer loop, so a 3 by 4 nest runs the inner body 12 times.FOR Row ← 1 TO 3
FOR Col ← 1 TO 4
OUTPUT Row, Col OUTPUT Row, Col
NEXT Col
NEXT RowFOR Day ← 1 TO 5
FOR Lap ← 1 TO 3
OUTPUT "Run" // runs 15 timesFOR Round ← 1 TO 3
WHILE Score < 10 DO
Score ← Score + 1WHILE Again = "Y" DO
REPEAT
INPUT Mark