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):
а[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)
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(int(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))
👍1