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 >= 12 then if hasTicket = true then | ANo indenting, so it is hard to see that the second if is nested inside the first. | |
| 2 end if end if | BEach if block gets its own end if. The inner one closes first, then the outer one | |
| 3The inner block is indented so you can see which if it belongs to | Cif raining = true then if haveUmbrella = true then print "Take umbrella" end if end if | |
| 4A nested if can do the same job as AND, because both conditions must be true for the action to run | DThe outer if has no end if. Every if, including the outer one, needs its own end if. | |
| 5if age >= 12 then if hasTicket = true then print "Enter" end if | EA nested if: the inner if is written inside the outer if, so hasTicket is only checked when age >= 12 is true | |
| 6if temp > 30 then if humid = true then print "Stay inside" end if end if | Fif score > 50 then if score > 90 then print "Top mark" end if end if |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
nested if — An if block written inside another if block. The inner condition is only checked when the outer condition is true. Indent the inner block and give each if its own end if.if age >= 12 then
if tall = true then print "Ride" end if
end ifif age >= 12 then
if tall = true then print "Ride" end if
end ifif score >= 50 then
if score >= 80 then print "Merit" end if
end ifif age >= 12 and tall = true then
print "Ride"
end ifif raining = true then
if windy = true then print "Coat" end if
end if