Quiz
Error Handling Quiz
What is the purpose of a try block in Python?
To define a function
To test code that might raise an exception
To create a loop
To handle files only
What will the code above print?
10 / 0
Cannot divide by zero!
Error message and program crashes
Nothing
Which exception is handled here?
TypeError
ZeroDivisionError
ValueError
FileNotFoundError
What is the purpose of using a tuple in the except statement?
To catch multiple types of exceptions in one block
To create multiple variables
To run the code twice
To define a list of numbers
When will the else block run?
Only if an exception occurs
Only if no exception occurs
Always
Never
What will happen even if an exception occurs?
The program crashes
The finally block runs
Nothing happens
Only the except block runs
Which of the following is NOT a common exception in Python?
ZeroDivisionError
ValueError
FileNotFoundError
LoopError