Program 33
Write a program to demonstrate Try/except/else.
try:
a=int(input("enter the A value:"))
b=int(input("enter the B value:"))
s=a/b
except ZeroDivisionError:
print("Can't divide by zero(b=0)")
else:
print("The division is=",s)
OUTPUT:
1.==== RESTART: C:/Users/crrcse/Desktop/36.py =======
enter the A value:27
enter the B value:3
The division is= 9.0
>>>
2.==== RESTART: C:/Users/crrcse/Desktop/36.py =======
enter the A value:70
enter the B value:0
Can't divide by zero(b=0)
>>>
No comments:
Post a Comment