Faulty Calculator

 '''

Design a calculator which will correctly solve all  the
problems except the following ones:
45*3=555, 56+9=77, 56/6=4
'''
import sys
def calculator():
    num1=int(input("enter first number: "))
    print('''
    Add.1
    Subtract.2
    Multiply.3
    Divide.4
    ''')
    choice=input("Choice opreations: ")
    num2=int(input("Enter second number: "))

    if num1==46 and choice=='*' and num2==3:
        print("555")

    elif num1==56 and choice=='+' and num2==9:
        print("77")

    elif num1==56 and choice=='/' and num2==6:
        print("4")

    elif choice=='+':
        print(num1+num2)
       

    elif choice=="-":
        print(num1-num2)

    elif choice=='*':
        print(num1*num2)

    elif choice=='/':
        print(num1/num2)

    else:
        print("Invailed opreations")

    record=input("Due want to calcualte more records(Y/N): ")
    if record=='y':
        calculator()

    else:
        print("Good Bye!")
        sys.exit()


calculator()


Comments

Popular posts from this blog

Become Healthy Goal - Python Program

Calculator in C++

Interpretation vs Compilation