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?
a = b, c = [1, 2]
a[0] = 10
print(b, c)
What will this code do?
def f():
x = 1
def g():
x += 1
g()
print(x)
print(f())
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(а, b):
а[0] = 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):
a = 2
b[0] = 10
x = 1
y = 1, 2
func(x, y)
print(x, y)
Given code
def f(a, b, c, d):
print(a, b, c, d)
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 your answer
Anonymous Quiz
13%
8
0%
21
25%
25
13%
28
38%
29
13%
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)