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?
a = 1 * 1
b = 1 / 1
print(a == 1, b == 1, a is 1, b is 1)
What will this code do?
class A:
def __init__(self, x):
self.x = x
def __getattribute__(self, name):
if name == '__add__':
self.x *= 10
return object.__getattribute__(self, name)
def __add__(self, other):
return self.x + other.x

a1 = A(2)
a2 = A(3)
print(a1 + a2, a1.__add__(a2))
๐Ÿ‘1
What will this code do?
S = 'abcdef'
print(S.islower() + S.lower().isalpha() + S.isupper())
What will this code do?
class A:
def __getitem__(self, i):
return i
a = A()
a.__getitem__ = lambda i: i**2

print(a[4])
๐Ÿ‘1
What will this code do?
from functools import reduce
print(reduce(lambda acc, x: x * acc, [1,2,3,4], 1))
๐Ÿ‘1
What will this code do?
class A:
x = 'hello'
def __getitem__(self, i):
return getattr(self.x, '__getitem__')(i) * 2
def __getattr__(self, attr):
return getattr(self.x, attr)
a = A()
print(a[0] + a.upper()[1:])
What will this code do?
f = type
print(f(f(f(f(f(None))))) is f )
What will this code do?
"hello, ะœะฐะบั!".encode('ascii', errors='replace')
What will this code do?
"hello, ะœะฐะบั!".encode('ascii', errors='ignore')
What will this code do?
class ะก: pass 
c = ะก()
a = type(c) == c.__class__
b = type(type(c)) is c.__class__.__class__
print(a, b)