-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.py
More file actions
58 lines (47 loc) · 1.52 KB
/
Copy path1.py
File metadata and controls
58 lines (47 loc) · 1.52 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# define the functions needed: add, sub, mul, div
# print options to the user
# ask for values
# call the function
# while loop to continue the program until the user wants to exit
def add(a, b):
answer = a + b
print(str(a) + " + " + str(b) + " = " + str(answer))
def sub(a, b):
answer = a - b
print(str(a) + " - " + str(b) + " = " + str(answer))
def mul(a, b):
answer = a * b
print(str(a) + " * " + str(b) + " = " + str(answer))
def div(a, b):
answer = a / b
print(str(a) + " / " + str(b) + " = " + str(answer))
while True:
print("A, Addition")
print("B, Subtraction")
print("C, Multiplication")
print("D, Division")
print("E, Exit")
choice = input("input your choice: ")
if choice == "a" or choice == "A":
print("Addition")
a = int(input("input first number: "))
b = int(input("input second number: "))
add(a, b)
elif choice == "b" or choice == "B":
print("Subtraction")
a = int(input("input first number: "))
b = int(input("input second number: "))
sub(a, b)
elif choice == "c" or choice == "C":
print("Multiplication")
a = int(input("input first number: "))
b = int(input("input second number: "))
mul(a, b)
elif choice == "d" or choice == "D":
print("Division")
a = int(input("input first number: "))
b = int(input("input second number: "))
div(a, b)
elif choice == "e" or choice == "E":
print("program ended")
quit()