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
🤯2🔥1
What will this code do?
class D:
__slots__ = ['a', 'b']
d = D()
d.a = 1
f = lambda attr: getattr(d, attr, '*')
print(f('a'), f('b'), f('__dict__'))
👍1
What will this code do?
import numpy as np
a = np.array([1, 2, 3])
n1 = round(np.linalg.norm(a, ord=np.inf), 1)
n2 = round(np.linalg.norm(a, ord=1), 1)
n3 = round(np.linalg.norm(a, ord=2), 1)
print(n1, n2, n3)
👍1
What will this code do?
6 + ~6
What will this code do?
class D:
__slots__ = ["a", "__dict__"]
def __init__(self):
self.b = 2
d = D()
d.a = 1
d.c = 3
print(sorted(d.__dict__.values()))
What will this code do?
g = (str(i**2) for i in range(1, 4))
print("".join(g) + "".join(g))
What will this code do?
f = lambda x: isinstance(x, int)
print(f(1), f(1.0), f(True), f(1j))
👍1
What will this code do?
(2 << 2) + (20 >> 2)
In what cases in Python 3 will the answer be an integer?
Anonymous Quiz
6%
8.0 - 3
11%
4/2
71%
7//2
0%
3/2
6%
4 + 1.0
3%
4.5 % 3
3%
See solution
What will this code do?
class MyList(list):
def __iter__(self):
return iter(self*2)
m = MyList([1, 2, 3])
print(list(m))
What will this code do?
from random import randint
num = randint(10**8, 10**20)
s = bin(num)[2:].replace('0', '\n').replace('1', '\t')
print(s.isspace())