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 variable is spelled nmae in print(), but it was created as name. This causes a NameError. Fix it by typing print(name). | |
| 2ZeroDivisionError: division by zero | BThe program tried to divide a number by 0, so it stopped running | |
| 3A ValueError happens when int() gets text that is not a whole number | Cage = int("hello") | |
| 4A runtime error stops the program at the line that fails, so later lines never run | Dprint("Start") x = 10 / 0 print("End") | |
| 5name = "Sam" print(nmae) | EThe program used a variable name that was never created, or it was spelled differently | |
| 6total = 50 share = total / 0 | FDividing by 0 causes a ZeroDivisionError. Fix it by dividing by a number that is not 0, such as total / 5. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
runtime error — An error that stops a program while it runs, shown as a named error like NameError, ValueError or ZeroDivisionError. Read the message to find the problem.score = 10
print(score)word = "cat"
num = int(word) # causes a ValueErrorpeople = 0
if people != 0:
print(10 / people)print(total)
# total was never made: NameError# This line causes a ZeroDivisionError
print(10 / 0)