Python & ML tasks
416 subscribers
2 photos
3 links
Python, functions, classes, iterators, generators, numpy, pandas, scikit-learn, TensorFlow
for advertising: @dina_ladnyuk

For advertising and donations in USD:
SWIFTBIC BUKBGB22
IBAN GB40 BUKB 2047 3453 2396 99
Mrs Dina Ladnyuk
Download Telegram
What will this code do?
def func(а, b):
а = 2
b = b[:]
b[0] = 10

a, b = [0], [1]
func(a, b)
print(a, b)
What will this code do?
def func(a, b):
а = 2
b[0] = 10
x = 1
y = 1, 2
func(x, y)
print(x, y)
The function is given:
def f(a, b, c, d):
print(a, b, c, d)
What will this code do?
x = 1
def f():
def g():
nonlocal x
print(x)
x += 1
return g
Given code:
def f(a, b, c, d, e):
print(a, b, c, d, e)

f(1, *(3,), c=10, **{"d": 5, "e": 100})
What will this code do?
def f(s:str = "1") -> int:
return s * 2
print(f(), isinstance(f(), int))
What will this code do?
def maker(f, args, kwargs):
return 1 + f(*args, **kwargs)
m1 = maker(lambda a, b: a + b, (5, ), {"b": 2})
m2 = maker(lambda a, b: a * b, [4, 5], {})
print(m1 + m2)
Choose the correct answer
Anonymous Quiz
7%
8
14%
21
14%
25
21%
28
36%
29
7%
See solution
What will this code do?
def f(test, *args):
res = []
for arg in args:
if test(arg):
res.append(arg)
return sum(res)
data = [-4, 2, -1, 5, -6, 3]
negative = lambda x: x < 0
neg = f(negative, *data)
positive = lambda x: x > 0
pos = f(positive, *data)
print(neg, pos)
What will this code do?
x = 1
def f():
def g():
nonlocal x
print(x)
x += 1
return g