forked from sabbott7/week6-debugging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator-runner.py
38 lines (31 loc) · 1.28 KB
/
calculator-runner.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
#this is the runner file, it is responsible for running your code from calculator.py
import calculator #this line imports your code
#let's greet the user and grab their input
print('Welcome to the calculator program!')
print('First, enter the first number you\'d like to use:')
first = int(input())
print('Great! Now enter the second number: ')
second = int(input())
choice = 0
#let's output a menu
while choice != 5:
print('Choose what you\'d like to do with ' + str(first) + ' and ' + str(second) + ':')
print('\t1: add')
print('\t2: subtract')
print('\t3: multiply')
print('\t4: divide')
print('\t5: exit')
choice = int(input())
# this series of if-statements call the proper functions from within the calculator program
if choice == 1:
print('The calculator returned: ' + str(calculator.add( first, second )))
elif choice == 2:
print('The calculator returned: ' + str(calculator.subtract( first, second )))
elif choice == 3:
print('The calculator returned: ' + str(calculator.multiply( first, second )))
elif choice == 4:
print('The calculator returned: ' + str(calculator.divide( first, second )))
elif choice == 5:
print('Goodbye!')
else:
print('Sorry that\'s not a valid choice. Try again.')