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 Mark < 0 AND Mark > 100 THEN | AWrong logical operator: OR is used where AND is needed, so every number counts as valid, even -5 or 120. Fix: use AND. | |
| 2IF Mark < 0 OR Mark > 100 THEN | BFaulty condition: no mark is below 0 and above 100 at the same time, so it is never TRUE and invalid marks are missed. | |
| 3Testing the faulty condition with an invalid value of 120 still gives FALSE, which shows the logic is wrong. | CMark ← 120 IF Mark < 0 AND Mark > 100 THEN | |
| 4To correct the error, change AND to OR so that either invalid case triggers the message. | DWrong logical operator: AND is used where OR is needed, so the condition is never TRUE and no invalid mark is ever reported. Fix: use OR. | |
| 5IF Mark < 0 AND Mark > 100 THEN OUTPUT "Invalid mark" ENDIF | ECorrect condition: TRUE for an invalid mark, because OR is TRUE when either part is TRUE. | |
| 6IF Mark >= 0 OR Mark <= 100 THEN OUTPUT "Valid mark" ENDIF | FIF Mark < 0 OR Mark > 100 THEN OUTPUT "Invalid mark" ENDIF |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Mark < 0 OR Mark > 100 — Use OR, not AND, to catch an invalid mark. A mark cannot be below 0 and above 100 at once, so AND is never TRUE. OR is TRUE when either part is TRUE.IF Mark < 0 OR Mark > 100 THENIF Mark >= 0 AND Mark <= 100 THEN
OUTPUT "Valid"
ENDIFWHILE Mark < 0 OR Mark > 100 DO
INPUT Mark
ENDWHILEMark ← 120
OUTPUT Mark < 0 OR Mark > 100
// Output: TRUEIF Mark < 0 OR Mark > 100 THEN
OUTPUT "Invalid mark"
ENDIF