Что выведет код?
x = 9
y = 2
divmod(x, y) == (x // y, x % y), divmod(x, y) is (x // y, x % y)
Выберите правильный вариант
Anonymous Quiz
19%
(True, True)
50%
(True, False)
10%
(False, True)
10%
(False, False)
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
16%
['D', 'A', 'B', 'X']
38%
['D', 'A', 'B', 'X', 'object']
26%
['D', 'A', 'X', 'B', 'object']
6%
['D', 'A', 'X', 'B']
14%
Посмотреть результаты
Что выведет код?
#задача
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))
Выберите правильный вариант
Anonymous Quiz
21%
3 3 3
28%
3 4 5
10%
3 5 3
21%
3 5 5
3%
3 5 6
16%
Посмотреть результаты
Что выведет код?
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()
👍1
Что выведет код?
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
29%
1 1 1
15%
1 1 2
10%
1 2 2
11%
2 2 2
29%
1 2 3
6%
Посмотреть результаты
Что выведет код?
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)
12%
(1, 3, 7)
17%
(1, 3, 0)
13%
(1, 2, 0)
16%
(1, 0, 0)
3%
(1, 3, 3)
12%
Посмотреть результаты
Что выведет код?
import random
random.random() < random.randint(1, 10)
Выберите правильный вариант
Anonymous Quiz
40%
True
9%
False
11%
AttributeError
6%
TypeError
26%
Неопределено
9%
Посмотреть результаты
Что выведет код?
(0 or 8 != 11 or 0) + (0 and 8 != 11 and 0)
Что выведет код?
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])
Выберите правильный вариант
Anonymous Quiz
2%
3
12%
6
13%
15
42%
16
13%
29
19%
Посмотреть результаты
Что выведет код?
def decorator(cls):
class Proxy:
def __init__ (self, *args):
self.wrapped = cls(*args)
def __getattr__(self, name):
return 1 if name == 'x' else getattr(self.wrapped, name)
return Proxy
@decorator
class S:
def __init__(self, x):
self.x = x
def square(self):
return self.x ** 2
s = S(10)
print(s.square() + s.x)
👍1
Выберите правильный вариант
Anonymous Quiz
1%
1
8%
10
9%
20
20%
100
41%
101
6%
110
1%
200
14%
Посмотреть результаты