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 >= 13: print('Teen') | ASyntaxError: expected ':'. The for line is missing the colon that opens the loop block. | |
| 2for i in range(3) print(i) | BUnexpected indent: print(x) is indented even though no block was opened above it. Remove the extra spaces so the line lines up with x = 5. | |
| 3Every line inside a block must be indented by the same amount so Python knows they belong together | Cdef greet(): print('Hi') | |
| 4A def line must end with a colon, followed by an indented body | DIndentationError: expected an indented block. The line after the colon is not indented, so Python can't tell it belongs inside the if. | |
| 5x = 5 print(x) | EMixing spaces and a tab: the last line is indented with a tab while the one above uses spaces. Use the same 4 spaces on both lines. | |
| 6if score > 5: print('Win') print('Done') | Fwhile lives > 0: print(lives) lives -= 1 |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
IndentationError — Python errors when a block's lines are not indented consistently, or when the if, for, while or def line that opens the block is missing its colon.age = 14
if age >= 13:
print("Teen")names = ["Ava", "Liam"]
for name in names:
print(name)count = 0
while count < 3:
print(count)def show_score(score):
print(score)
show_score(10)lives = 3
while lives > 0:
lives = lives - 1