Advertisements
Advertisements
प्रश्न
What will be the output of the following Python code?
try:
x = 10 / 0
except Exception:
print("Some other error!")
except ZeroDivisionError:
print("Division by zero error!")पर्याय
Division by zero error!
Some other error!
ZeroDivisionError
Nothing is printed
MCQ
Advertisements
उत्तर
Some other error!
Explanation:
ZeroDivisionError is a subclass of Exception.
Since the first except Exception: block matches all exceptions, it catches the error before ZeroDivisionError can.
So, the output is “Some other error!”
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
