Exceptions: IB Computer Science practice
try, except and debugging. 3 questions in the style of the IB Computer Science exam.
Sample questions
What does this program print?
attempts = 0
for v in ["12", "x", "0", "4"]:
try:
n = int(v)
print(12 // n)
except ValueError:
print("not a number")
except ZeroDivisionError:
print("cannot divide by zero")
finally:
attempts += 1
print(attempts, "attempts")