day 10
This commit is contained in:
28
10/task.py
Normal file
28
10/task.py
Normal 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
|
||||||
Reference in New Issue
Block a user