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 | |
|---|---|---|
| 1try: x = int('abc') exept: print('oops') | AOutput: error | |
| 2except: print('error') try: risky() | BValid: Catches ValueError only | |
| 3try: x = int(val) except ValueError: print('bad') | COutput: 5 | |
| 4try: risky() except: print('handled') | DError: Typo — 'except' not 'exept' | |
| 5try: print(int('hi')) except: print('error') | EError: try must come before except | |
| 6try: print(int('5')) except: print('error') | FOk: Catches any error |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
try — Block containing code that might cause an error.~~excepttry:
num = int(input('Number: '))
except:
print('Invalid')try:
num = int(input('Number: '))
except:
print('Invalid')try:
num = int(input('Number: '))
except ValueError:
print('Not a number')try:
result = 10 / 0
except:
print('Error')try:
x = int(input('Enter num: '))
except:
print('Bad input')