[enter image description here][1]```
def add(num1, num2):
return(num1 + num2)
def subtract(num1, num2):
return(num1 - num2)
def multiply(num1, num2):
return(num1 * num2)
def divide(num1, num2):
return int(num1 / num2)
operations = {
add,
subtract,
multiply,
divide,
> }
def calculator():
new_calc = True
while new_calc:
num1 = float(input("First number? "))
for symbol in operations:
print(symbol)
should_continue = True
while should_continue:
operation_symbol = input("Pick the operation: ")
num2 = float(input("Next number? "))
calculation_function = operations[operation_symbol]
answer = calculation_function(num1, num2)
print(f"{num1} {operation_symbol} {num2} = {answer}")
more = input(f"Continue with {answer}? type 'y' or 'n' for again, 'e' for exit..") == "y" or "n" or "e"
if more == "y":
num1 = answer
elif more == "n":
should_continue = False
else:
new_calc = False
calculator()
[1]: https://i.stack.imgur.com/4dIFW.png