Python Programming - Exception Handling - Discussion

Discussion Forum : Exception Handling - General Questions (Q.No. 21)
21.
Consider the following Python code:
try:
    result = 10 / 0
except ZeroDivisionError as e:
    result = "Error: " + str(e)
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, resulting in 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.