Program:
#1st Exception Handlingtry:
n1=int(input("Enter the 1st Number:"))
n2=int(input("Enter the 2nd Number:"))
except Exception as p:
print("\n\t--->>>WARNING:-",p)
try:
r1=n1/n2
r2=n1//n2
if r1>r2:
pass
else:
r1=r2
print("\nResult=",r1)
except Exception as e:
print("\t--->>>Exception is-",e)
try:
kn1=int(input("\nEnter any Number:"))
except Exception as e1:
print("\nSomething Went Wrong......\n","\t--->>>",e1)
Expected O/P:
case 1:
Enter the 1st Number:1
Enter the 2nd Number:0
--->>>Exception is- division by zero
Enter any Number:a ......{Here we enter Character value instead of the integer.}
Something Went Wrong......
--->>> invalid literal for int() with base 10: 'a'
>>>
case 2:
Enter the 1st Number:12
Enter the 2nd Number: .......{here we are not given any value just press Enter}
--->>>WARNING:- invalid literal for int() with base 10: ''
--->>>Exception is- name 'n2' is not defined
Enter any Number:10
>>>
0 Comments
Post a Comment