Python Exception Handling quiz (original) (raw)

What is an exception in Python?

How can you handle exceptions in Python?

What is the purpose of the finally block in exception handling?

Which of the following statements is used to raise a custom exception in Python?

What will be the output of the following code?

try:
result = 10 / 0
except ZeroDivisionError:
result = "Infinity"

print(result)

What is the purpose of the else block in exception handling?

How can you catch multiple exceptions in a single except block?

What is the purpose of the assert statement in Python exception handling?

What does the finally block execute if an exception is raised and not caught?

What is the purpose of the with statement in Python exception handling?

There are 24 questions to complete.

Take a part in the ongoing discussion