Question: Please answer questions where appropriate. Let x be a numpy array with 4 rows and 4 columns: x = numpy.array( [[ 1, 2, 3, 4],
Please answer questions where appropriate.
Let x be a numpy array with 4 rows and 4 columns:
x = numpy.array( [[ 1, 2, 3, 4],
[ 5, 6, 7, 8],
[ 9, 10, 11, 12],
[13, 14, 15, 16]])
What is the result of the following operations (answer questions A-L)? Please append with detailed comments about why.
A. y = x[:, 2]
B. y = x[-1,:2]
C. y = x[:, [True, False, False, True]]
D. y = x[0:2, 0:2]
E. y = x[[0, 1, 2], [0, 1, 2]]
F. y = x[0]**2
G. y = x.max(axis=1)
H. y = x[:2, :2] + x[:2,2:]
I. y = x[:2, :3].T
J. y = x[:2, :3].reshape((3, 2))
K. y = x[:, :2].dot([1, 1])
L. y = x[:, :2].dot([[3, 0], [0, 2]])
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
