# Exception handling
N1 = eval(input("Enter number : "))
N2 = eval(input("Enter number : "))
try:
Res = N1/N2
except ZeroDivisionError as e:
print("ZeroDivisionError : ",e)
except:
print("Unknown error")
else:
print("Division = ",round(Res,4))
finally:
print("Exception handling complete.")
"""
Sample output
>python EH3.py
Enter number : 4
Enter number : 6
Division = 0.6667
Exception handling complete.
>python EH3.py
Enter number : 4
Enter number : 'e'
Unknown error
Exception handling complete.
>python EH3.py
Enter number : 4
Enter number : 0
ZeroDivisionError : division by zero
Exception handling complete.
"""
No comments:
Post a Comment
Don't be a silent reader...
Leave your comments...
Anu