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
What will this code do?
class MyList(list):
def __iter__(self):
return iter(self*2)
m = MyList([1, 2, 3])
print(list(m))
Choose your answer
Anonymous Quiz
0%
[]
16%
[1, 2, 3]
58%
[1, 2, 3, 1, 2, 3]
13%
TypeError
0%
IndexError
13%
See solution
🤔1
What will this code do?
from random import randint
num = randint(10**8, 10**20)
s = bin(num)[2:].replace('0', '\n').replace('1', '\t')
print(s.isspace())
Choose your answer
Anonymous Quiz
9%
0
4%
1
39%
True
26%
False
4%
\n
0%
\t
9%
TypeError
9%
See solution
What will this code do?
S = " \t \n "
S.isalpha() + S.isspace() + S.isdigit() + S.isprintable()
What will this code do?
from math import log
from functools import reduce
f = lambda acc, x: x * acc
gen = (abs(log(i / 10)) for i in range(1, 1000))
print(int(reduce(f, gen, 1)))
Choose your answer
Anonymous Quiz
0%
-1
20%
0
15%
1
30%
10
20%
17844
5%
None
5%
ValueError
5%
See solution