2. Programming Fundamentals

Error Handling — Quiz

Test your understanding of error handling with 5 practice questions.

Read the lesson first

Practice Questions

Question 1

Which of the following is an example of an exception in programming?

Question 2

What is the primary purpose of a try block in exception handling?

Question 3

Which keyword is used to explicitly raise an exception in Python?

Question 4

What is the role of an except block in error handling?

Question 5

Consider the following Python code snippet:

python
def divide(a, b): try: result = a / b except TypeError: return "Type Error" except ZeroDivisionError: return "Division by Zero Error" else: return result print(divide(10, 0))


What will be the output of this code?
Error Handling Quiz — Computer Science | A-Warded