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 score > 50: | Afor i in range(1, 11): | |
| 2for i in range(1, 5): | Baverage = total / 3 total = a + b + c | |
| 3A logic error: the average is worked out before the total has been added up, so the answer is wrong | CThe statements are in the wrong order, so print runs before total is set. Put total = 5 + 10 first, then print(total). | |
| 4Fixing an off-by-one error so a loop prints every number from 1 to 10 | DA 13 year old is left out because > was used instead of >=. Use age >= 13 to include 13. | |
| 5if age > 13: print("Teen") | ESkips a score of exactly 50, so a student who needs to score 50 or more to pass would wrongly fail | |
| 6print(total) total = 5 + 10 | FCounts only 1, 2, 3, 4 and stops before 5, so it is off by one if you wanted 1 to 5 |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
logic error — A mistake that lets a program run with no error message but give the wrong result, caused by a wrong condition, operator (> or >=), range() off by one, or steps in the wrong order.score = 50
if score >= 50:
print("Pass")# Print the numbers 1 to 5
for i in range(1, 6):
print(i)total = 0
total = total + 5
print(total)score = 100
if score > 100:
print("Bonus!")# Say hi 3 times
for i in range(3):
print("Hi")