-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunit1_ex1.1.3.py
More file actions
36 lines (28 loc) · 854 Bytes
/
unit1_ex1.1.3.py
File metadata and controls
36 lines (28 loc) · 854 Bytes
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
# exercise 1.1.3 from unit 1
'''
Write a function called four_dividers defined as follows:
def four_dividers(number):
The function accepts a number and returns a list of
all numbers from 1 to that number (inclusive) that are
divisible by four without a remainder.
Examples of running the four_dividers function:
print(four_dividers(9))
print(four_dividers(3))
[4, 8]
[]
Guidelines:
It is forbidden to use an external library, except
the functools library.
Do not use loops.
The four_dividers function block must contain only one
line of code.
You can implement an additional auxiliary function as you wish.
'''
def four_dividers(number):
def is_divisible_by_four(x):
return x % 4 == 0
return list(filter(is_divisible_by_four, range(1, number + 1)))
def main():
print(four_dividers(20))
if __name__ == "__main__":
main()