Question 7
Back to Exercise
What is the output of the following Python program?
class InsufficientFunds(Exception):
pass
try:
raise InsufficientFunds("need 500 more")
except Exception as e:
print(type(e).__name__, "-", e, isinstance(e, Exception))
- A Exception - need 500 more True
- B InsufficientFunds - InsufficientFunds False
- C need 500 more
- D InsufficientFunds - need 500 more True Correct
Correct Answer: Option D
except Exception catches the subclass; the object keeps its own class name and message.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!