diff --git a/10/task.py b/10/task.py new file mode 100644 index 0000000..07b062a --- /dev/null +++ b/10/task.py @@ -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 \ No newline at end of file