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 OUTPUT "Child" ELSE OUTPUT "Teen" | AThe THEN and ELSE outputs are swapped. A temperature over 30 is hot, but the algorithm says "Cold day". Fix it by swapping the two outputs. | |
| 2IF mark < 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" | BThe condition tests the opposite of what is intended, so low marks pass and high marks fail. Flip the condition to mark >= 50 or swap the two outputs. | |
| 3A correct decision sends the true (Yes) path to the matching result: if the score is 10 or more, the output is "Win". | CThe Yes and No paths are swapped: a 15-year-old is told "Child" and an 8-year-old is told "Teen", the opposite of what is right. | |
| 4To check for swapped branches, test one input for each branch and compare the traced output with what you expect. | DIF score >= 10 THEN OUTPUT "Win" ELSE OUTPUT "Lose" | |
| 5IF temp > 30 THEN OUTPUT "Cold day" ELSE OUTPUT "Hot day" | EThe Yes and No paths are the wrong way round, so the right password is refused and a wrong one is let in. Swap the two outputs, or change the condition to password != correct. | |
| 6IF password = correct THEN OUTPUT "Access denied" ELSE OUTPUT "Welcome" | Fscore <- 12, expected "Win", traced "Lose"; score <- 3, expected "Lose", traced "Win" |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
swapped branches — The THEN and ELSE paths are the wrong way round, so the algorithm gives the opposite result for every input. Fix it by swapping the two paths or by flipping the condition.IF mark >= 50 THEN OUTPUT "Pass"
ELSE OUTPUT "Fail"
ENDIFIF temp < 15 THEN OUTPUT "Cold"
ELSE OUTPUT "Warm"
ENDIFIF raining = TRUE THEN OUTPUT "Umbrella"
ELSE OUTPUT "Sunscreen"
ENDIFIF age >= 18 THEN OUTPUT "Adult"
ELSE OUTPUT "Child"
ENDIFIF light = "red" THEN OUTPUT "Stop"
ELSE OUTPUT "Go"
ENDIF