Skip to content

Calculator in Python

Source Code

a = int(input("Number1: "))
b = int(input("Number2: "))

c = str(input("Symbol: "))

print("---------------------------------------------------")
print("RESULT:")

match c:
    case '+':
        print(a,c,b,"=",a+b)
    case '-':
        print(a,c,b,"=",a-b)
    case '*':
        print(a,c,b,"=",a*b)
    case '/':
        if b == 0:
            print("ERROR CANT DIVIDE BY 0!!!!")
            pass
        else:
            print(a,c,b,"=",a/b)