8.
Write a function named DivExp which takes TWO parameters a, b and
returns a value c (c=a/b). Write suitable assertion for a>0 in function DivExp
and raise an exception for when b=0. Develop a suitable program which reads
two values from the console and calls a function DivExp.
Program:
def DivExp(a,b):
try:
c=a/b
except ZeroDivisionError:
print('Error: Division by zero')
else:
return c
a = int(input('Enter the Divident value of \'a\': '))
b = int(input('Enter the Divisor value of \'b\': '))
d = DivExp(a,b)
if d is not None:
print('The result of division is: ', d)
else:
print('The result of division is: infinity')
OUTPUT
Enter the Divident value of 'a': 6
Enter the Divisor value of 'b': 0
Error: Division by zero
The result of division is: infinity
Enter the Divident value of 'a': 8
Enter the Divisor value of 'b': 2
The result of division is: 4.0
[ ]: