-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimple_dict.py
54 lines (35 loc) · 1.13 KB
/
simple_dict.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
48
49
50
51
52
53
54
def add(first_number, second_number):
return first_number + second_number
def sub(first_number, second_number):
return first_number - second_number
def mul(first_number, second_number):
return first_number * second_number
def div(first_number, second_number):
return first_number / second_number
def divint(first_number, second_number):
return first_number // second_number
def mod(first_number, second_number):
return first_number % second_number
def pow(first_number, second_number):
return first_number ** second_number
def calc(first_number, second_number, symbol):
ops = {
"+": add,
"-": sub,
"*": mul,
"/": div,
"div": divint,
"mod": mod,
"pow": pow
}
return ops[symbol](first_number, second_number)
def main():
first_number = float(input())
second_number = float(input())
symbol = input()
if second_number == 0 and (symbol == "mod" or symbol == "/" or symbol == "div"):
print("Division by 0 is impossible!")
return
print(calc(first_number, second_number, symbol))
if __name__ == "__main__":
main()