forked from ZCW-Spring26/SciCalcPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain-app.py
More file actions
34 lines (24 loc) · 681 Bytes
/
Copy pathmain-app.py
File metadata and controls
34 lines (24 loc) · 681 Bytes
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
from calculator import Calculator
def getTwoNumbers():
a = float(input("first number? "))
b = float(input("second number? "))
return a, b
def displayResult(x: float):
print(x, "\n")
def performCalcLoop(calc):
while True:
choice = input("Operation? ")
if choice == 'q':
break # user types q to quit calulator.
elif choice == 'add':
a, b = getTwoNumbers()
displayResult(calc.add(a, b))
else:
print("That is not a valid input.")
# main start
def main():
calc = Calculator()
performCalcLoop(calc)
print("Done Calculating.")
if __name__ == '__main__':
main()