-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.py
More file actions
70 lines (42 loc) · 1.38 KB
/
calculator.py
File metadata and controls
70 lines (42 loc) · 1.38 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
61
62
63
64
65
66
67
68
69
70
def add(x, y):
result = int(x) + int(y)
print(f"x : {x} and y : {y} and x + y : {result}")
def minus(x, y):
result = int(x) - int(y)
print(f"x : {x} and y : {y} and x + y :{result}")
def multiplication(x, y):
result = int(x) * int(y)
print(f"x : {x} and y : {y} and x + y :{result}")
def divide(x, y):
result = int(x) / int(y)
print(f"x : {x} and y : {y} and x + y :{result}")
def guide():
print("------------------------------------")
print("for add enter <<a>>")
print("for minus enter <<m>>")
print("for multiplication enter <<mu>>")
print("for divide enter <<d>>")
print("for Exit enter <<e>>")
print("------------------------------------")
options =['a', 'm', 'mu', 'd', 'e']
def calculate():
guide()
while True:
user = input("what do you do ?").lower()
while user not in options:
user = input("what do you do ?")
x = input("please enter X : ")
print()
y = input("please enter Y : ")
if user == "a":
add(x, y)
elif user == "m":
minus(x ,y)
elif user == "mu":
multiplication(x ,y)
elif user == "d":
divide(x ,y)
elif user == "e":
break
print("good bye")
calculate()