-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions.py
More file actions
21 lines (21 loc) · 771 Bytes
/
exceptions.py
File metadata and controls
21 lines (21 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
print("Addition\nSubtraction\nMultiplication\nDevision")
try:
first_number = int(input("First Number: "))
operator = input("Operator: ").lower()
second_number = int(input("Second Number: "))
result = 0
if operator == "addition":
result = first_number + second_number
elif operator == "subtraction":
result = first_number - second_number
elif operator == "multiplication":
result = first_number * second_number
elif operator == "devision":
result = first_number / second_number
else:
print("Sorry I don't understand your operator!!!")
print(result)
except ValueError as e:
print("Invalid input.")
except ZeroDivisionError:
print("For Devision Second number must be non-zero number.")