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 | |
|---|---|---|
| 1IF Age >= 13 THEN IF HasTicket = TRUE THEN OUTPUT "Enter" ENDIF ENDIF | AThe inner IF checks the ticket only when the outer condition Age >= 13 is true, and each IF has its own ENDIF. | |
| 2IF Score >= 50 THEN OUTPUT "Pass" ELSE IF Score >= 40 THEN OUTPUT "Resit" ENDIF ENDIF | BIF Age >= 13 AND HasTicket = TRUE THEN OUTPUT "Enter" ENDIF | |
| 3Indentation shows the levels of nesting: the inner IF, its statements and its ENDIF are indented further than the outer IF. | CThe ENDIFs are in the wrong order or indentation. The outer ENDIF is written before the inner ENDIF, so the nesting is muddled. | |
| 4A nested IF can often be replaced by one IF with AND, when both conditions must be true and there is no ELSE. | DThe inner IF is only checked when Score >= 50 is false, so it handles the scores that failed the first test. | |
| 5IF Age >= 13 THEN IF HasTicket = TRUE THEN OUTPUT "Enter" ENDIF | EThe inner IF has no ENDIF of its own. The only ENDIF is used up by one IF, so the other IF is left unclosed. | |
| 6IF Score >= 50 THEN IF Score >= 80 THEN OUTPUT "Merit" ENDIF ENDIF | FIF X > 0 THEN IF X < 10 THEN OUTPUT "Small" ENDIF ENDIF |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
nested IF — An IF placed inside the THEN or ELSE branch of another IF. It is only checked when that outer branch runs, and each IF needs its own ENDIF, with the inner ENDIF written first.IF age >= 16 THEN
IF hasTicket = TRUE THEN
OUTPUT "Enter" OUTPUT "Pass"
ENDIF
ENDIFELSE
IF temp < 10 THEN
OUTPUT "Cold"IF age >= 16 AND hasId = TRUE THEN
OUTPUT "Enter"
ENDIFIF raining = TRUE THEN
IF windy = TRUE THEN
OUTPUT "Stay in"