Files
python_bootcamp/10/task.py
Tanguy Deleplanque b77a884c67 day 10
2025-06-17 17:44:13 +02:00

28 lines
697 B
Python

def calc(a, b, operation):
return(eval(f"{a} {operation} {b}"))
a = input("What's your first number?:")
b_calculate = True
while b_calculate:
for operator in ["+", "-", "/", "*"]:
print(operator)
operation = input("Pick an operation:")
b = input("What's the next number?:")
result = str(calc(a, b, operation)).removesuffix(".0")
print(f"{a} {operation} {b} = {result}")
choice = input(f"Type 'y' to continue calculating with {result} or type 'n' to start a new calculation")
match(choice):
case "y":
a = result
case "n":
a = input("What's your first number?:")
case _:
b_calculate = False