import numpy as np
arr = np.arange(4)
# Return evenly spaced values within a given interval.
arr_bool = np.array([True, False, True, False, True])
selected = arr[arr_bool]Quiz 2
Module 3: NumPy
import numpy as np
x = np.array(
[[1, 2],
[3, 4]]
)
x[1, :] = 0
print(x)import numpy as np
a = np.array([1, 2, 3])
b = np.array([[4, 5, 6], [7, 8, 9]])
c = b > a
print(c)import numpy as np
games = np.array(
[[0, 1, 0],
[1, 0, 0],
[0, 1, 0]]
)
# Make Python choose door number 2
print(games[:, 1])
# Compute our avg. gains
gains = np.sum(games) / len(games)
print(gains)import numpy as np
a = np.zeros(3).astype(float)
c = np.ones(5, dtype=bool)
d = np.ones((5, 5))
b = np.zeros(3, 3)