Choose your answer
Anonymous Quiz
4%
2
6%
3
13%
6
55%
8
1%
None
16%
TypeError: 'A' object is not callable
4%
See solution
What will this code do?
from functools import reduce
funcs = [str.title, lambda x: x*2]
print(reduce(lambda acc, f: f(acc), funcs, 'hello'))
What will this code do?
class A:
def __init__(self, x):
self._x = x
@property
def x(self):
return self._x
a = A(1)
print(A.x.fget(a), a.x)
Choose your answer
Anonymous Quiz
14%
1 None
6%
None 1
34%
1 1
3%
None None
23%
AttributeError
3%
TypeError
0%
ValueError
17%
See solution
Choose your answer
Anonymous Quiz
23%
False False
22%
False True
38%
True False
12%
True True
5%
See solution
What will this code do?
a = 0
def func():
global a
for num in [2, 4, 8]:
a += 1
yield(num * 0.5)
array = []
for val in func():
array.append(int(a == val))
print(sum(array))
👍1
What will this code do?
a = 1; b = 2
print(eval('print(a + b, end=" ") or 0'))
Choose your answer
Anonymous Quiz
7%
0
27%
3
12%
3 None
20%
3 0
0%
None 3
18%
SyntaxError
17%
See solution
Which of the following expressions will not return True?
Anonymous Quiz
8%
a.x == 1
17%
a.y == 2
10%
A.x == 1
37%
A.y == 2
8%
a.__dict__['y'] == 2
10%
A.__dict__['x'] == 1
12%
See solution
What will this code do?
class A:
def __iter__(self):
yield from range(10)
a = A()
print(5 in a, 20 in a)
What will this code do?
def g(f1, f2, x):
return f1(x) + f2(x) if x else 0
f1, f2 = lambda x: x**3/abs(x), lambda x: x % 2
x = 121
g(f1, f2, -x) + g(f1, f2, x)