Python Tasks & ML | Задачи по питону и машинному обучению
9.39K subscribers
27 photos
1 file
36 links
Algorithms, functions, classes, regular expressions, iterators, generators, OOP, exceptions, NumPy, pandas, scikit-learn
https://telega.in/c/python_tasks

Questions — @dina_ladnyuk
Download Telegram
Что выведет код?
s = list(map(lambda x, y: x + y, [1, 2, 3], [4, 5, 6]))
print(s)
Что выведет код?
def f(p, q):
return p + q

x = list(map(f, ('a', 'b', 'c'), ('x', 'y', 'z')))
print(x[1])
Что выведет код?
tup = (5, 7, 22, 97)
newtup = tuple(map(lambda x: x + 3, tup))
print(newtup)
👍2
Что выведет код?
x = 5
print([y%2 for y in range(6)][x])
👍2
Что выведет код?
def func(x):
if x >= 3:
return x
y = filter(func, (1, 2, 3, 4))
print(list(y))
Что выведет код?
def f(x):
if x < 3:
return x
y = filter(f, (0, 1, 2, 3, 4))
print(list(y))
Что выведет код?
def f():
import sys
locs = sys._getframe(1).f_locals
setattr(locs['self'], 'xy', 4*locs['x'] + 7*locs['y'])

class A:
def __init__(self, x, y):
self.xy = 2*x + 3*y
f()

a = A(2, 3)
A.xy = 99
print(a.xy)
👍2
Что выведет код?
from functools import reduce
y = reduce(lambda a, b: a + b , [1, 2, 3, 4])
print(y)
Что выведет код?
x = {1: "A", 3: "B"}
y = {2: "C", 3: "D", 4: "E"}
d = {**x, **y}
vals = sorted(d.values())
print(*vals)
🔥4
Что выведет код?
c = map(lambda x: x + x, filter(lambda x: (x>3), (1, 2, 3, 4)))
print(list(c))
👍3
Что выведет код?
c = filter(lambda x: x>=3, map(lambda x: x+x, (1, 2, 3, 4)))
print(list(c))