-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalulator2.py
More file actions
60 lines (47 loc) · 1.5 KB
/
calulator2.py
File metadata and controls
60 lines (47 loc) · 1.5 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
59
60
# define the functions needed: add, div,sub,multi
# print options to the user
# ask for values"
# call the function
# while loop to continue the program until the user exits
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 the first number:"))
b = int(input("input second number:"))
mul(a, b)
elif choice == "d" or choice == "D":
print("Divison")
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()