Python & ML tasks
415 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?
class A:
def __init__(self, value):
self.value = value
def __call__(self, other):
return self.value ** other
x = A(2)
print(x(3))
What will this code do?
from functools import reduce
funcs = [str.title, lambda x: x*2]
print(reduce(lambda acc, f: f(acc), funcs, 'hello'))
What will this code do?
class A:
def __init__(self, x):
self._x = x
@property
def x(self):
return self._x

a = A(1)
print(A.x.fget(a), a.x)
What will this code do?
a = {1, 2, 3}
b = {3, 2, 1}
print(a == b, a is b)
What will this code do?
print(sorted([str(x) for x in range(1, 30, 5)]))
What will this code do?
print(2 ^ 3 ^ 3 ^ 2 ^ 2 ^ 4 ^ 2 ^ 4 ^ 2)
Choose your answer
Anonymous Quiz
28%
0
7%
1
18%
2
0%
3
0%
4
5%
7
43%
See solution
What will this code do?
a = 0
def func():
global a
for num in [2, 4, 8]:
a += 1
yield(num * 0.5)

array = []
for val in func():
array.append(int(a == val))
print(sum(array))
👍1
What will this code do?
a = 1; b = 2
print(eval('print(a + b, end=" ") or 0'))
Given code
class A:
x = 1
def __init__(self):
self.y = 2

a = A()
What will this code do?
class A:
def __iter__(self):
yield from range(10)
a = A()
print(5 in a, 20 in a)