Choose your answer
Anonymous Quiz
35%
[[1 2 3 4 5 6]]
26%
[1, 2, 3, 4, 5, 6]
21%
[[1], [2], [3], [4], [5], [6]]
5%
[1]
14%
See solution
What will this code do?
class A:
def __repr__(self):
return "repr"
def __str__(self):
return "str"
a = A()
print(a, repr(a), str(a))
Choose your answer
Anonymous Quiz
4%
str str str
8%
repr str repr
52%
str repr str
31%
repr repr str
2%
str repr repr
0%
repr repr repr
2%
See solution
Choose your answer
Anonymous Quiz
9%
'3'
2%
[3]
11%
ord('3')
2%
ord('3')
42%
3
7%
51
15%
'0b11'
2%
bin(3)
11%
See solution
What will this code do?
(lambda: lambda: lambda: lambda: lambda: 1)()()()()()
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'))