-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlesson15.py
More file actions
36 lines (28 loc) · 755 Bytes
/
lesson15.py
File metadata and controls
36 lines (28 loc) · 755 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
with open('lesson15.txt', 'r') as file:
line_num = int(file.readline())
for i in range(line_num):
a, b = map(int, file.readline().split())
print(a+b)
def f(a, b):
return a * b
a = map(f, [2, 4, 5], [5, 6 ,7])
print(list(a))
a = map(f, [2, 4, 5], [5, 6])
print(list(a))
a = map(lambda x: x+10, (2, 4, 5))
print(list(a))
def f(a):
if a % 2 == 0:
return a
a = filter(f, (2,3,4,5,6))
print(list(a))
# because i have to put else after if in lambda func i can finish it with "False" or "0"
a = filter((lambda a: a if a%2==0 else False or 0), (2,3,4,5,6))
print(list(a))
# Reduce
from functools import reduce
print(reduce(lambda a,b: a*b, (2,3,4)))
a = [1,2,3,4,5,6,7]
b = 'qwerty'
res = zip(a, b)
print(list(res))