-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calculating_with_Functions.py
68 lines (38 loc) · 1.26 KB
/
Calculating_with_Functions.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
def operator(operation, y):
operators = {
"plus": y + operation["number"],
"minus": y - operation["number"],
"times": y * operation["number"],
"divided_by": y // operation["number"] if operation["number"] else 1,
}
return operators[operation["operation"]]
def number_foo(operation, n):
return operator(operation, n) if operation else n
def zero(operation=None):
return number_foo(operation, 0)
def one(operation=None):
return number_foo(operation, 1)
def two(operation=None):
return number_foo(operation, 2)
def three(operation=None):
return number_foo(operation, 3)
def four(operation=None):
return number_foo(operation, 4)
def five(operation=None):
return number_foo(operation, 5)
def six(operation=None):
return number_foo(operation, 6)
def seven(operation=None):
return number_foo(operation, 7)
def eight(operation=None):
return number_foo(operation, 8)
def nine(operation=None):
return number_foo(operation, 9)
def plus(n):
return {"operation": "plus", "number": n}
def minus(n):
return {"operation": "minus", "number": n}
def times(n):
return {"operation": "times", "number": n}
def divided_by(n):
return {"operation": "divided_by", "number": n}