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 0 <= mark <= 100: | AThe second comparison is missing the variable name. It should be mark <= 100, or use 0 <= mark <= 100. | |
| 2if age < 0 or age > 120: | Belse: print("Mark must be 0 to 100") | |
| 3Boundary values 0 and 100 must be accepted, so use <= rather than < on both sides | CDetects an out-of-range age: True when age is below the minimum or above the maximum | |
| 4Show an error message when the number is outside the allowed range | Dif 0 <= mark <= 100: | |
| 5if 0 < mark < 100: | EUses < instead of <=, so the boundary values 0 and 100 are wrongly rejected. It should be 0 <= mark <= 100. | |
| 6if mark >= 0 and <= 100: | FA chained comparison range check that is True only when mark is from 0 to 100 inclusive |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
if 0 <= mark <= 100: — A range check tests that a number lies between a minimum and maximum. This chained comparison is True only when mark is from 0 to 100 inclusive, so the boundary values 0 and 100 are accepted.if 0 <= mark <= 100:if 0 <= mark <= 100:if 0 <= mark <= 100:
print("Mark accepted")if not 0 <= mark <= 100:
print("Mark must be 0 to 100")if mark >= 0 and mark <= 100:
print("Valid")