Choose your answer
Anonymous Quiz
9%
2
19%
3
30%
4
5%
5
5%
True
5%
False
5%
None
12%
TypeError
0%
SyntaxError
12%
See solution
What will this code do?
import numpy as np
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
c = a + b
c = c * a
print(c[1])
🤩1
👍1
What will this code do?
def f(n):
s = 0
for i in range(n):
s += i
s += ~i
return s
print(f(1) + f(10) + f(100))
🤩1
Choose your answer
Anonymous Quiz
5%
-9990
0%
-4995
19%
-111
14%
0
12%
111
12%
4995
10%
9990
29%
See solution
🎉2
👍2
Which of the classes from the scikit-learn library does NOT solve the problem of regression?
Anonymous Quiz
17%
DecisionTreeRegressor
20%
RandomForestRegressor
20%
LinearRegression
37%
LogisticRegression
7%
See solution
👍1
What will this code do?
class MyList(list):
def __getitem__(self, index):
if type(index) is slice:
index = slice(index.start - 1, index.stop - 1, index.step)
elif type(index) is int:
index -= 1
return list.__getitem__(self, index)
l = MyList(["one", "two", "three", "four", "five", "six"])
print(l[1], l[-1], l[0], l[2:4])
What will this code do?
a = 1 * 1
b = 1 / 1
print(a == 1, b == 1, a is 1, b is 1)
How to print python philosophy?
Anonymous Quiz
37%
import this
12%
import philosophy
20%
print(__philosophy__)
6%
print(__pypy__)
4%
print()
8%
exec('__ph__')
14%
See solution
🤯2
What will this code do?
class A:
def __init__(self, x):
self.x = x
def __getattribute__(self, name):
if name == '__add__':
self.x *= 10
return object.__getattribute__(self, name)
def __add__(self, other):
return self.x + other.x
a1 = A(2)
a2 = A(3)
print(a1 + a2, a1.__add__(a2))
👍1
Choose your answer
Anonymous Quiz
22%
5 5
5%
23 5
38%
5 23
14%
23 23
8%
NameError
3%
RecursionError
11%
See solution
🎉1
What will this code do?
S = 'abcdef'
print(S.islower() + S.lower().isalpha() + S.isupper())
Choose your answer
Anonymous Quiz
2%
0
2%
1
41%
2
0%
3
12%
6
2%
True
10%
False
20%
TypeError
10%
See solution
👍1
What will this code do?
class A:
def __getitem__(self, i):
return i
a = A()
a.__getitem__ = lambda i: i**2
print(a[4])
Choose your answer
Anonymous Quiz
9%
4
9%
8
62%
16
2%
None
17%
IndexError
0%
TypeError
2%
See solution
👍1
What will this code do?
from functools import reduce
print(reduce(lambda acc, x: x * acc, [1,2,3,4], 1))