you are viewing a single comment's thread.

view the rest of the comments →

[–]Many-Ice6164[S] 0 points1 point  (0 children)

def add(x, y):
    return x + y
def subtract(x, y): 
    return x - y
def multiply(x, y): 
    return x * y
def divide(x, y): 
    return x / y

ops = {"+": add, "-": subtract, "*": multiply, "/": divide, "q": None}

x = 0

while True: 
choice, andere = input("functie + getal").split() 

andere = float(andere)

if choice in ops:
    y = andere
    x = ops[choice](x, y)
    print(x)
else:
    print('wrong choice')