day 14 + cleanup

This commit is contained in:
Tanguy Deleplanque
2025-06-20 11:45:12 +02:00
parent 07f37394d9
commit 7f9b263baa
6 changed files with 349 additions and 1 deletions

28
010/task.py Normal file
View File

@ -0,0 +1,28 @@
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