-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
64 lines (47 loc) · 1.75 KB
/
main.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'''Main program for calculator.
Author: Syed Saif
Created at: 21-12-2021
...
'''
import config as c
from calculation import Calculation
print(c.greeting_message)
print()
while True:
try:
operation_choice = int(input(
f'''{c.operation_message}
{({k:v for k, v in c.operations_config.items()})}'''))
if operation_choice == 8:
print(c.exit_message)
break
result = 'No result'
if 7 >= operation_choice >= 1:
first_number = int(input("Enter the First Number: "))
second_number = int(input("Enter the Second Number: "))
calc = Calculation()
else:
print(f'Enter the choice between {c.operations_config.keys()}')
if operation_choice == 1:
result = calc.addition(first_number, second_number)
elif operation_choice == 2:
result = calc.subtraction(first_number, second_number)
elif operation_choice == 3:
result = calc.multiplication(first_number, second_number)
elif operation_choice == 4:
result = calc.division(first_number, second_number)
elif operation_choice == 5:
result = calc.modulo(first_number, second_number)
elif operation_choice == 6:
result = calc.exponential(first_number, second_number)
elif operation_choice == 7:
result = calc.floor_division(first_number, second_number)
print(f'result = {result}')
except ValueError as v:
print(f'Value error due to {v}')
except NameError as n:
print(f'Name error due to {n}')
except ZeroDivisionError:
print(f'Name error due to {n}')
except Exception as e:
print(f'Error occured due to {e}')