FAULT CALCULATOR IN PYTHON DAY 8
# Exercise 2 - Faulty Calculator
# 45 * 3 = 555, 56+9 = 77, 56/6 = 4
# Design a calculator which will correctly solve all the problems except
# the following ones:
# 45 * 3 = 555, 56+9 = 77, 56/6 = 4
# Your program should take operator and the two numbers as input from the user
# and then return the result
print("Enter the function "
"+ for Addition"
"- for Subtraction"
"* for Multiplication"
"/ for division ")
f= input()
print("Enter first number")
a=int(input())
print("Enter second number")
b=int(input())
if a==45 and b==3 and f=="*":
print("Answer is 555")
elif a==56 and b==9 and f=="+":
print("Answer is 77")
elif a==56 and b==6 and f=="/":
print("Answer is 4")
elif f=="+":
print(a+b)
elif f=="-":
print(a-b)
elif f=="*":
print(a*b)
elif f=="/":
print(a/b)
Comments
Post a Comment