How to merge two dictionaries into one?
x and y are dictionaries.
x and y are dictionaries.
Anonymous Quiz
39%
z = {**x, **y}
15%
z = {x + y}
11%
z = {*x, *y}
28%
z = x + y
7%
See solution
What will this code do?
s = list(map(lambda x, y: x + y, [1, 2, 3], [4, 5, 6]))
print(s)
Choose your answer
Anonymous Quiz
17%
[1, 2, 3, 4, 5, 6]
65%
[5, 7, 9]
2%
21
9%
AttributeError
7%
See solution
What will this code do?
import numpy as np
mtx=np.array([[1, 2],
[3, 4]])
print(mtx.shape)
What will this code print?
Anonymous Quiz
27%
Number of rows and columns as a tuple
41%
Number of total elements
24%
Number of dimensions
8%
See solution
Fill in the gap
def gt_100(x):
if x > 100:
return True
else:
return False
import numpy as np
matrix = np.array([[99, 101], [100, 102]])
#your code
gt_100(matrix)
What will this code do?
tup = (5, 7, 22, 97)
newtup = tuple(map(lambda x: x + 3, tup))
print(newtup)
Choose your answer
Anonymous Quiz
21%
[8, 10, 25, 100]
67%
(8, 10, 25, 100)
5%
<map object at 0x000001D7B2539F28>
3%
None
5%
Error
0%
See solution
What will this code do?
import numpy as np
a = np.array([[101, 99],[102, 98]])
print(np.max(a))
Choose your answer
Anonymous Quiz
0%
101
77%
102
14%
[102, 98]
3%
[101, 99]
3%
Error
3%
See solution
What will this code do?
def func(x):
if x >= 3:
return x
y = filter(func, (1, 2, 3, 4))
print(list(y))
👍2
What will this code do?
def func(x):
if x < 3:
return x
y = filter(func, (0, 1, 2, 3, 4))
print(list(y))
Choose your answer
Anonymous Quiz
75%
[0, 1, 2]
18%
[1, 2]
0%
[2]
3%
(0, 1, 2)
0%
(1, 2)
0%
(2)
3%
None
3%
TypeError
0%
See solution
What will this code do?
def f():
import sys
locs = sys._getframe(1).f_locals
setattr(locs['self'], 'xy', 4*locs['x'] + 7*locs['y'])
class A:
def __init__(self, x, y):
self.xy = 2*x + 3*y
f()
a = A(2, 3)
A.xy = 99
print(a.xy)