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 | |
|---|---|---|
| 1ELSE IF Mark >= 60 THEN OUTPUT "Merit" ENDIF ENDIF | AA second IF placed inside the ELSE branch, so it is only tested when the first condition was false. | |
| 2IF Mark >= 70 THEN OUTPUT "Distinction" ELSE IF Mark >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" ENDIF ENDIF | BIF Mark >= 80 THEN Grade <- "A" ELSE IF Mark >= 50 THEN Grade <- "B" ELSE Grade <- "C" ENDIF ENDIF | |
| 3Grade boundaries must be ordered from the highest boundary down, so a mark of 85 is tested against 80 before 50. | CThe conditions are in the wrong order. Any mark of 50 or more is caught by the first IF, so the test for 80 can never run and A is never given. | |
| 4Every IF needs its own ENDIF, so a structure with two IFs closes with two ENDIF lines. | DIF Score >= 40 THEN OUTPUT "Pass" ELSE IF Score >= 20 THEN OUTPUT "Resit" ELSE OUTPUT "Fail" ENDIF ENDIF | |
| 5IF Mark >= 50 THEN Grade <- "C" ELSE IF Mark >= 80 THEN Grade <- "A" ENDIF ENDIF | EThe nested IF has no ENDIF of its own. Two IFs need two ENDIFs, but only one is written. | |
| 6IF Mark >= 70 THEN OUTPUT "Distinction" ELSE IF Mark >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" ENDIF | FThree alternatives where only one message is output, and it needs two ENDIFs because there are two IFs. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
ELSE IF — A nested IF placed inside ELSE to choose between 3+ alternatives. Conditions are tested in order, only one branch runs, and every IF needs its own ENDIF.IF Mark >= 70 THEN
OUTPUT "A"
ELSE
IF Mark >= 50 THEN OUTPUT "B"
ENDIF
ENDIFIF Mark >= 70 THEN
OUTPUT "A"
ELSEELSE
IF Mark >= 50 THEN
OUTPUT "B"IF Mark >= 70 THEN
OUTPUT "A"
ELSE