Выберите правильный вариант
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%
Посмотреть результаты
Что выведет код?
sum(divmod(16,5), 5)
Что выведет код?
def f(x, y):
return x ** y
print(f.__call__(3, 2) + f(2, 3))
Выберите правильный вариант
Anonymous Quiz
2%
8
2%
9
4%
10
8%
16
65%
17
2%
27
8%
AttributeError
10%
Посмотреть результаты
Что выведет код?
"{0:b}{1:#o}".format(3, 8)
👍1
Выберите правильный вариант
Anonymous Quiz
12%
'1110'
16%
'11o10'
26%
'110o10'
12%
'0o1011'
25%
'110b1000'
10%
'30o10'
Как вывести список установленных библиотек Python?
Anonymous Quiz
16%
pip show
1%
pip search
3%
pip check
70%
pip list
1%
pip completion
2%
pip cache
7%
Посмотреть результаты
Что выведет код?
d = {"id": 1, "person": {"name": "Vasya", "age": 18}}
d1 = d.copy()
d1["person"]["age"] += 1
d2 = d
d2["person"]["age"] += 1
print(d["person"]["age"])