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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
