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?
x = 1
def f():
def g():
nonlocal x
print(x)
x += 1
return g
What will this code do?
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
0%
8
9%
21
9%
25
18%
28
55%
29
9%
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?
def f(transform, *args):
res = args[0]
for arg in args[1:]:
res = transform(res, arg)
return res

data = [-4, 2, -1, 5, -6, 3]
func = lambda x, n: x * (-1)**n
print(f(func, *data))
What will this code do?
def mintwo(*args):
tmp = list(args)
tmp.sort()
return tmp[0], tmp[1]
data = [8, -4, 5, -2, 9, 3, -98]
print(*mintwo(*data))
What will this code do?
def f(*args):
result = []
for x in args[0]:
if x in result:
continue
for word in args[1:]:
if x not in word:
break
else:
result.append(x)
return ''.join(result)
s1, s2, s3= "message", "massage", "mask"
print(f(s1, s2, s3))
What is the way to verify that the variable `a` in connection with none, is it preferable?
Anonymous Quiz
15%
if not a:
31%
if a == None:
38%
if a is None:
15%
if bool(a) == False:
0%
if bool(a) is False:
What will this code do?
def f(*args):
result = []
for x in args[0]:
for word in args[1:]:
if x not in word:
break
else:
result.append(x)
return ''.join(result)
s1, s2, s3= "message", "massage", "mask"
print(f(s1, s2, s3))