-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGroup_1.py
38 lines (34 loc) · 1.44 KB
/
Group_1.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
'''
Calculator app that calculates result of two numbers from user and then loops
Asks user for two numbers
User then chooses what calculation they want to do
Calculator will output result and then loop to asking for user to input numbers
To-do:
make the input invalid print statement re-loop, without asking for numbers again
'''
print("***** Welcome to the Super Calculator!! *****")
def calculator():
#asks user for first number, then displays it
first_num = float(input('Please enter your first number: '))
print(first_num)
#asks user for second number, then displays it
second_num = float(input('Please enter your second number: '))
print(second_num)
#aks user for type of calculation
print("What would you like to do?")
operation = str(input('Input one of the following; +, -, * or /?: '))
#calculates result and displays it
if operation in ('+', '-', '*', '/'):
if operation == '+':
print(first_num, "+", second_num, "=", first_num + second_num)
elif operation == '-':
print(first_num, "-", second_num, "=", first_num - second_num)
elif operation == '*':
print(first_num, "*", second_num, "=", first_num * second_num)
elif operation == '/':
print(first_num, "/", second_num, "=", first_num / second_num)
else:
print('Input invalid')
# keeps the calculator running/looping
while True:
calculator()