-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht1.py
47 lines (33 loc) · 761 Bytes
/
t1.py
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
def _sum(x, y):
result = int(x) + int(y)
return result
def mul(x, y):
result = int(x) * int(y)
return result
def sub(x, y):
result = int(x) - int(y)
return result
def greeting():
result = "salam man injam"
return result
def find_max(x, y):
result = int(x) - int(y)
return result
commands = {
"sum": _sum,
"mul": mul,
"sub": sub,
"hello": greeting,
"max": find_max
}
while True:
user_inp = input().split(" ")
if user_inp[0] == "exit":
print("program ended successfully!")
break
else:
function = commands[user_inp[0]]
if len(user_inp) == 3:
print(function(x=user_inp[1], y=user_inp[2]))
elif len(user_inp) == 1:
print(function())