-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path7_calculator.py
42 lines (32 loc) · 1.02 KB
/
7_calculator.py
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
37
38
39
40
41
42
print("Welcome to the CALCULATOR")
op = ('''
+
-
*
/
''')
def operations(first, second, calc):
if calc == '+' :
ans = first + second
return f"{first} {calc} {second} = {ans}"
elif calc == '-' :
ans = first - second
return f"{first} {calc} {second} = {ans}"
elif calc == '*' :
ans = first * second
return f"{first} {calc} {second} = {ans}"
elif calc == '/' :
ans = first / second
return f"{first} {calc} {second} = {ans}"
end_calc = False
while not end_calc:
first_number = int(input("What is the first number: "))
print(op)
operation = input("Pick an operation: ")
second_number = int(input("What is the next number: "))
answer1 = operations(first=first_number, second=second_number, calc=operation)
print(answer1)
cont = input("Type 'y' to continue calculating or type 'n' to stop: ")
if cont == 'n':
end_calc = True
print('Goodbye')