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?
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())
What will this code do?
S = "  \t \n  "
S.isalpha() + S.isspace() + S.isdigit() + S.isprintable()
What will this code do?
from math import log
from functools import reduce
f = lambda acc, x: x * acc
gen = (abs(log(i / 10)) for i in range(1, 1000))
print(int(reduce(f, gen, 1)))