-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay-10
41 lines (33 loc) · 825 Bytes
/
Day-10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from art import logo
def sum(a,b):
return a+b
def minus(a,b):
return a-b
def multiply(a,b):
return a*b
def devide(a,b):
return a/b
operators = {
"+" : sum,
"-" : minus,
"*" : multiply,
"/" : devide,
}
def calculator():
print(logo)
n1 = float(input("What is your first number?: "))
for one in operators:
print(one)
check = True
while check:
symbol = input("Choose an operator: ")
n2 = float(input("What's the next number?: "))
operation = operators[symbol]
ans = operation(n1,n2)
print(f" {n1} {symbol} {n2} = {ans}")
if input(f"Type 'y' continue with {ans}, or type 'n' to start a new calculation: ") == "y":
n1 = ans
else :
calculator()
check = False
calculator()