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 | |
|---|---|---|
| 1WHILE age < 12 OR age > 18 | AA range check condition: the loop keeps repeating while the age falls outside the allowed range of 12 to 18 | |
| 2WHILE name = "" | BThe loop never asks for input again, so age never changes and the loop repeats forever after an invalid entry. | |
| 3After a failed check, show an error message and ask the user to enter the value again inside the loop | CA presence check condition: the loop repeats while nothing has been entered | |
| 4Read the first input before the loop so the condition has a value to test | Dinput age WHILE age < 12 OR age > 18 print "Age must be 12 to 18" input age ENDWHILE | |
| 5input age WHILE age < 12 OR age > 18 print "Age must be 12 to 18" ENDWHILE | EThe condition tests for VALID input, so the loop runs and shows an error when the age is correct, but accepts invalid ages. | |
| 6input age WHILE age >= 12 AND age <= 18 print "Age must be 12 to 18" input age ENDWHILE | FWHILE score < 0 OR score > 100 print "Enter a score from 0 to 100" input score ENDWHILE |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
while input is invalid — A loop that reads input, tests it (presence, type, range or length), then shows an error message and asks again until the input passes the check.while age < 1 OR age > 120
print "Age must be 1-120"
input agewhile LENGTH(name) = 0
print "Name cannot be blank"
input namewhile mark < 0 OR mark > 100
print "Mark must be 0-100"
input markwhile score < 0 OR score > 10
print "Enter a score from 0 to 10"
input scorewhile LENGTH(pin) ≠ 4
print "PIN must be 4 digits"
input pin