Python Programming - Exception Handling - Discussion

Discussion Forum : Exception Handling - General Questions (Q.No. 2)
2.
Consider the following Python code:
try:
    result = 10 / 0
except ZeroDivisionError:
    result = "Error: Division by zero"
What will be the value of "result" after the execution of this code?
10
0
"Error: Division by zero"
None
Answer: Option
Explanation:
The code attempts to divide by zero, which raises a ZeroDivisionError. The exception is caught, and "result" is assigned the string "Error: Division by zero."
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.