Quick actions

cmd+k|ctrl+k

Navigation

Languages

Calculator A

Snippet info

Language

Python

Visibility

public

Author

hohim4095

Created

2024-10-17T12:47:55.386525Z

Updated

2024-10-17T12:54:17.264189Z

x = input("Please input an expression")
y = x.split()
print(y)
a = float(y[0])
b = y[1]
c = float(y[2])
if (type(a) == int or type(a) == float) and (b in ['+','-','x','/']):
    if (type(c) == int or type(c) == float):
        if b=='+':
            result = a + c
        if b == '-':
            result = a - c
        if b == 'x':
            result = a * c
        if b == '/':
            result = a/c
        print(result)
else:
    print("input error")
INFO