A faulty calculator which give some different value for some values
#Exercise Faulty Calculator
#45*3=555, 56+9=77,56/6=4
# We have to make faulty calculator which will give the incorrect value for these number else give correct value for any other operation
def add(a,b):
result=(a+b)
print(result)
def sub(a,b):
result=(a-b)
print(result)
def mul(a,b):
result=(a*b)
print(result)
def div(a,b):
result=(a/b)
print(result)
a=int(input("Enter the first number: "))
b=int(input("Enter the second number: "))
op=input("Enter the opearator: ")
if a==45 and b==3 and op== '*' :
print(555)
elif a==56 and b==9 and op== '+' :
print(77)
elif a==56 and b==6 and op== '/' :
print(4)
elif op=="+":
print(add(a,b))
elif op=="-":
print(sub(a,b))
elif op=="*":
print(mul(a,b))
elif op=="/":
print(div(a,b))
else:
print("Enter the correct opearator" )
Comments
Post a Comment