-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (41 loc) · 923 Bytes
/
main.py
File metadata and controls
43 lines (41 loc) · 923 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
35
36
37
38
39
40
41
42
43
"""
Main file.
PS: Chris, if you are reading this, know that we are doing this homework in our lunch break.
"""
from src.calculator import Calculator
calc = Calculator()
num1 = float(input("Enter the first number: "))
calc.set_value(num1)
num2 = float(input("Enter the second number: "))
print(
"\nOptions:\n" +
"1. Add\n" +
"2. Subtract\n" +
"3. Multiply\n" +
"4. Divide\n" +
"5. Power\n" +
"6. Root\n"
)
choice = input("Enter your choice: ")
try:
choice = int(choice)
except ValueError:
print("Not a number!")
exit(1)
if choice == 1:
calc.add(num2)
elif choice == 2:
calc.subtract(num2)
elif choice == 3:
calc.multiply(num2)
elif choice == 4:
calc.divide(num2)
elif choice == 5:
calc.power(num2)
elif choice == 6:
calc.root(num2)
else:
print("Invalid choice!")
exit(1)
print("\nResult: " + str(calc.get_value()))
input("\nPress ENTER to exit...")