-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator.py
More file actions
38 lines (35 loc) · 1.43 KB
/
Calculator.py
File metadata and controls
38 lines (35 loc) · 1.43 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
33
34
35
36
37
38
def addition(first_number,second_number):
ans = int(first_number)+int(second_number)
print("The answer is: " + str(ans))
def subtraction(first_number,second_number):
ans = int(first_number)-int(second_number)
print("The answer is: "+str(ans))
def multiplication(first_number,second_number):
ans = int(first_number)*int(second_number)
print("The answer is: " + str(ans))
def division(first_number,second_number):
ans = int(first_number)/int(second_number)
print("the answer is: " + str(ans))
print("Welcome to The Calculator")
operation = input("Please enter the operation that you wish to perform: ")
if operation.lower() == "addition":
x = input("Please enter the first number: ")
y = input("Please enter the second number: ")
addition(x,y)
elif operation.lower() == "subtraction":
x = input("Please enter the first number: ")
y = input("Please enter the second number: ")
subtraction(x,y)
elif operation.lower() == "multiplication":
x = input("Please enter the first number: ")
y = input("Please enter the second number: ")
multiplication(x,y)
elif operation.lower() == "Division":
x = input("Please enter the first number: ")
y = input("Please enter the second number: ")
try:
division(x, y)
except ZeroDivisionError:
print("The division of any number by 0 is not possible.")
else:
print("Please enter a valid operation")