-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfullcalculator.py
More file actions
32 lines (26 loc) · 1 KB
/
fullcalculator.py
File metadata and controls
32 lines (26 loc) · 1 KB
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
from calculator import Calculator
from checkinput import *
calculator = Calculator()
def calculate():
first_int = numbercheck("What's your first integer? ")
operand = operandcheck('''What's your operand you'd like to use?
(You may use '+' or '-' or '*' or '/' or '!'.) ''')
if operand == '!':
answer = calculator.fact(first_int)
else:
second_int = numbercheck("What's your second integer? ")
if operand == '+':
answer = calculator.add(first_int,second_int)
elif operand == '-':
answer = calculator.sub(first_int,second_int)
elif operand == '*':
answer = calculator.mult(first_int,second_int)
elif operand == '/':
answer = calculator.div(first_int,second_int)
else:
print('''You did not enter a valid operand in step 2, sorry!
Exiting program, please try again.''')
return
print("Congratulations! Your answer is {0}.".format(answer))
print(chr(27) + "[2J")
calculate()