Choose your answer
Anonymous Quiz
0%
[1, 2]
12%
[1, 2, 1, 2]
42%
[2, 4]
35%
[3, 6]
0%
TypeError
4%
IndexError
8%
See solution
👍2
What will this code do?
def invertdict(D):
def keysof(V):
return sorted(K for K in D.keys() if D[K] == V)
return {V: keysof(V) for V in set(D.values())}
D = {'x': 'a', 'y': 'b', 'z': 'a'}
print(invertdict(D))
What will this code do?
s = "Hello, world!"
s.find("world", 0, 7) + s.find("world", 5)
🤯2🔥1
What will this code do?
class D:
__slots__ = ['a', 'b']
d = D()
d.a = 1
f = lambda attr: getattr(d, attr, '*')
print(f('a'), f('b'), f('__dict__'))
👍1
Choose your answer
Anonymous Quiz
8%
1 1 1
8%
1 1 *
50%
1 * *
8%
* * *
0%
* 1 1
0%
* * 1
25%
See solution
👍1
What will this code do?
import numpy as np
a = np.array([1, 2, 3])
n1 = round(np.linalg.norm(a, ord=np.inf), 1)
n2 = round(np.linalg.norm(a, ord=1), 1)
n3 = round(np.linalg.norm(a, ord=2), 1)
print(n1, n2, n3)
👍1
Choose your answer
Anonymous Quiz
23%
3.0 6.0 3.7
32%
3.0 3.7 6.0
9%
3.7 6.0 3.0
0%
3.7 1.0 3.0
36%
See solution
👍1
What will this code do?
class D:
__slots__ = ["a", "__dict__"]
def __init__(self):
self.b = 2
d = D()
d.a = 1
d.c = 3
print(sorted(d.__dict__.values()))
Choose your answer
Anonymous Quiz
40%
[1, 2, 3]
8%
[1, 2]
24%
[2, 3]
8%
[1, 3]
4%
[1]
0%
[2]
12%
AttributeError
4%
See solution
👍1🤔1
What will this code do?
g = (str(i**2) for i in range(1, 4))
print("".join(g) + "".join(g))
Choose your answer
Anonymous Quiz
0%
14
3%
116
3%
123
3%
1234
35%
149
42%
149149
3%
14916
10%
1491614916
0%
See solution
What will this code do?
f = lambda x: isinstance(x, int)
print(f(1), f(1.0), f(True), f(1j))
👍1
Choose your answer
Anonymous Quiz
0%
True True True True
7%
True True False True
53%
True False True False
0%
True True False False
40%
True False False False
👍1
In what cases in Python 3 will the answer be an integer?
Anonymous Quiz
6%
8.0 - 3
11%
4/2
71%
7//2
0%
3/2
6%
4 + 1.0
3%
4.5 % 3
3%
See solution