Что выведет код?
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%
Посмотреть результаты
Что выведет код?
def counter(func):
def oncall(*args):
oncall.calls += 1
return func(*args) + oncall.calls
oncall.calls = 0
return oncall
class C:
@counter
def square(self, a):
return a ** 2
x = C()
print(x.square(2) + x.square(2))
Что выведет код?
class A: pass
class B:
def __init__(self):
x = super()
print(x is A, x is B)
b = B()
Выберите правильный вариант?
Anonymous Quiz
16%
True True
21%
True False
33%
False True
24%
False False
6%
Посмотреть результаты
Что выведет код?
def f(*, name):
print(len(name), end=" ")
try:
f(name="vasya")
f("sergey")
except:
f(name="oleg")
Выберите правильный вариант
Anonymous Quiz
11%
4
22%
5 6
9%
5 6 4
5%
6 4
36%
5 4
9%
TypeError
8%
Посмотреть результаты