Выберите правильный вариант
Anonymous Quiz
4%
1
6%
10
7%
20
16%
100
39%
101
11%
110
4%
200
13%
Посмотреть результаты
Что выведет код?
class counter:
def __init__(self, func):
self.calls = 0
self.func = func
def __call__(self, *args):
self.calls += 1
return self.func(*args), self.calls
@counter
def square(a):
return a ** 2
print(square(2)[0] + square(3)[0] + square(4)[1])
👍4
Выберите правильный вариант
Anonymous Quiz
7%
3
12%
6
14%
15
39%
16
12%
29
16%
Посмотреть результаты
👍2
Что выведет код?
(0 or 8 != 11 or 0) + (0 and 8 != 11 and 0)
👍5
Выберите правильный вариант
Anonymous Quiz
19%
True
20%
False
15%
0
33%
1
10%
2
3%
Посмотреть результаты
👍2
Что выведет код?
import random
random.random() < random.randint(1, 10)
Выберите правильный вариант
Anonymous Quiz
39%
True
10%
False
12%
AttributeError
10%
TypeError
20%
Неопределено
9%
Посмотреть результаты
Что выведет код?
class A:
count = 0
@classmethod
def inc(cls):
cls.count += 1
def __init__ (self):
self.inc()
class B(A):
count = 0
def __init__(self):
A.__init__(self)
class C(A):
count = 0
x = A()
y1, y2 = B(), B()
z1, z2, z3 = C(), C(), C()
print(x.count, y1.count, z1.count)
Выберите правильный вариант
Anonymous Quiz
28%
1 2 3
6%
1 3 7
12%
1 3 0
19%
1 2 0
19%
1 0 0
2%
1 3 3
13%
Посмотреть результаты
👍2
Что выведет код?
class A:
count = 0
def __init__(self) :
self.__class__.count += 1
class B(A):
pass
class C(A):
pass
x, y, z = B(), A(), C()
print(A.count, B.count, C.count)
Выберите правильный вариант
Anonymous Quiz
40%
1 1 1
13%
1 1 2
7%
1 2 2
9%
2 2 2
25%
1 2 3
6%
Посмотреть результаты
👍4
Что выведет код?
class A:
count = 0
def __init__(self):
A.count += 1
def print_count():
print(A.count)
print_count = staticmethod(print_count)
class B(A): pass
x, y, z = B(), A(), B()
B.print_count()
Выберите правильный вариант
Anonymous Quiz
19%
1
22%
2
41%
3
5%
4
8%
AttributeError
5%
Посмотреть результаты
👨💻3🔥2
Что выведет код?
class A:
count = 0
def __init__(self):
A.count = A.count + 1
def get(self):
return A.count
x, y, z = A(), A(), A()
print(x.get(), A().__class__.get(A()), z.__class__.get(y))
👍1
Выберите правильный вариант
Anonymous Quiz
28%
3 3 3
20%
3 4 5
11%
3 5 3
24%
3 5 5
6%
3 5 6
11%
Посмотреть результаты
Что выведет код?
class X: pass
class A(X): pass
class B(X): pass
class D(A, B): pass
print([cls.__name__ for cls in D.__mro__])
Выберите правильный вариант
Anonymous Quiz
22%
['D', 'A', 'B', 'X']
38%
['D', 'A', 'B', 'X', 'object']
14%
['D', 'A', 'X', 'B', 'object']
12%
['D', 'A', 'X', 'B']
14%
Посмотреть результаты
👍4🔥1🤔1
Что выведет код?
x = 9
y = 2
print(divmod(x, y) == (x // y, x % y), divmod(x, y) is (x // y, x % y))
Выберите правильный вариант
Anonymous Quiz
25%
True True
43%
True False
15%
False True
10%
False False
7%
Посмотреть результаты
👍4
Что выведет код?
class C: pass
class D (C): __slots__ = ['a']
X = D()
X.a = 1
class A: __slots__ = ['b']
class B (A): __slots__ = ['b']
Y = B()
Y.b = 1
print(hasattr(X, '__dict__'), hasattr(Y, '__dict__'))
👍2