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 | |
|---|---|---|
| 1NameError: name 'score' is not defined | AThe list only has positions 0 and 1, so index 2 does not exist. Use names[1] to get the last item. | |
| 2File "game.py", line 12, in <module> | BIndexError: list index out of range | |
| 3An IndexError means you asked for a list position that does not exist | CA SyntaxError means the code breaks Python's grammar rules. Here a closing bracket is missing, so add ) at the end of the line. | |
| 4A TypeError happens when you combine values of the wrong types, like a string and an integer | DPython met a variable name it has never seen, often from a typo or using it before it was created | |
| 5File "app.py", line 5 print("Hi" ^ SyntaxError: '(' was never closed | EThe traceback line that shows which file and which line number to start looking for the bug | |
| 6names = ['Ava', 'Ben'] print(names[2]) IndexError: list index out of range | FTypeError: can only concatenate str (not "int") to str |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Traceback (most recent call last): — The start of Python's error report. It names the error type (like NameError) and the line number where it happened, so you know where to start looking for the bug.NameError: name 'scor' is not definedage = 15
print("Age: " + age)
TypeError: can only concatenate strcolours = ["red", "blue"]
print(colours[5])
IndexError: list index out of rangeprint("Hello"
SyntaxError: '(' was never closed File "main.py", line 3, in <module>