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: "A", 3: "B"}
y = {2: "C", 3: "D", 4: "E"}
d = {**x, **y}
vals = sorted(d.values())
print(*vals)
What will this code do?
def outer():
x = "local"
def inner():
nonlocal x
x = "nonlocal"
print(x, end=" ")
inner()
print(x)
outer()
What will this code do?
def gen():
for i in range(3):
yield i
for item in gen():
print(item, end=" ")
Choose your answer
Anonymous Quiz
10%
0 1 2 3
70%
0 1 2
0%
0 1
5%
1 2 3
15%
3
What will this code do?
import itertools
list1 = [1, 2]
list2 = ['a', 'b']
result = list(itertools.product(list1, list2))
print(result)
What will this code do?
from functools import reduce
class MyList:
def __init__(self, *args):
self.items = list(args)

def __len__(self):
return reduce(lambda acc, x: acc + (sum(x) if hasattr(x, '__iter__') else x), [x*2 for x in self.items])

my_list = MyList(1, 2, 3, [4, 5])
print(len(my_list))
Choose your answer
Anonymous Quiz
0%
15
0%
24
0%
25
38%
30
25%
50
38%
See solution
What will this code do?
a = {1, 2, 9}
b = {2, 3, 9}
c = a & b
c.remove(2)
print(*c)
What will this code do?
a = {1, 2}
b = {2, 3}
c = (a | b) - (a & b)
d = a ^ b
print(c == d)
What will this code do?
a, b = {1, 2}, {2, 3}
c = a - b
d = b - a
print(*(c & d), *(c | d))
What will this code do?
my_list = [1, 2, 3, 4, 5]
r = [x % 3 for x in my_list]
print(sum(r))
What this code do?
class A:
__x = 1
def f(self):
return "f from A"

def g(self):
return "g from A"

class B:
__x = 2
def f(self):
return "f from B"

def g(self):
return "g from B"

class C(A, B):
f = B.f

c = C()
print(c.f(), c.g(), c._A__x, c._B__x)