write a python function that accepts the value of two integers a and b and produces the output as (a+b)/(a-b). As he is still a kid, hence might not be able to enter the values correctly. Write a python function Divide_Op(a,b) (Refer RollNo_W10A_3.py) which produces the appropriate output or error message by handling all possible exceptions.
def Divide_Op(a,b):
if (a-b) == 0:
print("can not divide a number by zero")
else:
answer = (a+b)/(a-b)
return answer
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
output = Divide_Op(num1,num2)
print("(",num1,"+",num2,")/(",num1,"-",num2,") = ", output)
Comments
Leave a comment