Choose your answer
Anonymous Quiz
3%
None
37%
1
3%
lambda
25%
<function <lambda> at 0x110a8ae18>
0%
TypeError
29%
SyntaxError
4%
See solution
Choose your answer
Anonymous Quiz
2%
None
12%
1
58%
3
3%
lambda
9%
<function <lambda> at 0x110a8ae18>
8%
TypeError
9%
SyntaxError
0%
SyntaxError
Choose your answer
Anonymous Quiz
2%
None
5%
1
52%
3
3%
lambda
7%
<function <lambda> at 0x110a8ae18>
7%
TypeError
22%
SyntaxError
2%
SyntaxError
What do you need to add to make the code work?
class A:
def __init__(self, x):
self.x = x
def __and__(self, other):
return self.x + other.x
a1 = A(1)
a2 = A(2)
# your code
output: 3
Choose your answer
Anonymous Quiz
36%
print(a1 and a2)
34%
print(a1 & a2)
7%
print(a1 && a2)
9%
print(a1 | a2)
5%
print(a1 ^ a2)
9%
See solution
What will this code do?
def f(n):
x, y = -n, -n
return x is y
print(f(0), f(5), f(10))
What will this code do?
class A:
def __init__(self, value):
self.value = value
def __call__(self, other):
return self.value ** other
x = A(2)
print(x(3))
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