-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.py
More file actions
43 lines (36 loc) · 1.01 KB
/
Copy pathcalculator.py
File metadata and controls
43 lines (36 loc) · 1.01 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
39
40
41
42
43
# add num_1 to num_2
def add(num_1, num_2):
return num_1 + num_2
# subtract num_1 from num_2
def subtract(num_1, num_2):
return num_1 - num_2
# multiple num_1 and num_2
def multiply(num_1, num_2):
return num_1 * num_2
# divide num_1 by num_2
def divide(num_1, num_2):
return num_1 / num_2
def operationName(num):
if num == "1":
return "Add"
elif num == "2":
return "Subtract"
elif num == "3":
return "Multiple"
else:
return "Divide"
print("Operator choices:")
print("1. Add")
print("2. Subtract")
print("3. Multiple")
print("4. Divide")
operation = input("Enter operator 1, 2, 3 or 4):")
if operation in ("1", "2", "3", "4"):
if operation != "1":
print(f"{operationName(operation)} still under development.")
else:
first_input = int(input("Enter first number: "))
second_input = int(input("Enter second number: "))
print(first_input, "+", second_input, "=", add(first_input, second_input))
else:
print("Invalid input")