Make a faulty calculator using python
By using the given below python code you can make a faulty calculator which will give wrong values in your first three attempts (THE FAULTY VALUES ARE GIVEN IN THE CODE AS A COMMENT STATEMENT) and after that all other values will be correct
I HOPE YOU WOULD LIKE IT
print("welcome to faulty calculator")
#faulty values are 56+9=77,4-2=1,5/5=10 and 7*7=1
num1=int(input("enter your first number"))
num2=int(input("enter your next number"))
opertor=input("choose any operators")
if opertor=='+':
if num1==56 and num2==9:
print("77")
else:
print(num1+num2)
elif opertor=='-':
if num1==4 and num2==2:
print("1")
else:
print(num1-num2)
elif opertor=='/':
if num1==5 and num2==5:
print("10")
else:
print(num1/num2)
elif opertor=='*':
if num1==7 and num2==7:
print("1")
else:
print(num1*num2)
Comments
Post a Comment