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 ← 2 TO 10 STEP 2 | AFOR Number ← 3 TO 1 STEP -1 OUTPUT Number NEXT Number | |
| 2FOR Count ← 5 TO 1 STEP -1 | BThis outputs 1, 3, 5, 7, 9 (odd numbers) not the even numbers. To output even numbers it should start at 2: FOR Count ← 2 TO 10 STEP 2. | |
| 3STEP sets how much the loop variable changes each time round, so STEP 2 gives the even numbers 2, 4, 6, 8, 10 | CThere is no STEP -1, so the loop counts up by 1 by default. Because 10 is already past 1, the loop body never runs. It should be FOR Count ← 10 TO 1 STEP -1. | |
| 4A negative STEP counts down, and the loop ends when the value goes past value2 (below 1 here) | DFOR Number ← 2 TO 10 STEP 2 OUTPUT Number NEXT Number | |
| 5FOR Count ← 10 TO 1 OUTPUT Count NEXT Count | ECounts in twos: Count takes the values 2, 4, 6, 8, 10, so the loop runs 5 times | |
| 6FOR Count ← 1 TO 10 STEP 2 OUTPUT Count NEXT Count | FCounts down: Count takes the values 5, 4, 3, 2, 1, so the loop runs 5 times |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
STEP — Sets how much the FOR loop variable changes each time round. STEP 2 counts in twos and STEP -1 counts down. The loop stops when the value goes past the end value.FOR Num ← 2 TO 10 STEP 2
OUTPUT Num
NEXT NumFOR Count ← 10 TO 1 STEP -1
OUTPUT Count
NEXT CountFOR Num ← 0 TO 10 STEP 2
OUTPUT Num
NEXT NumFOR Num ← 10 TO 0 STEP -2
OUTPUT Num
NEXT NumFOR Count ← 20 TO 0 STEP -5
OUTPUT Count
NEXT Count