निम्नलिखित कोड का परिणाम क्या है ?
What is the output of the following code ?
import numpy as np
y = np.array([[11, 12, 13, 14], [32, 33, 34, 35]])
print(y.ndim) A
1
B
2
C
3
D
0
Explanation
Let's analyze the code:
import numpy as np
y = np.array([[11, 12, 13, 14], [32, 33, 34, 35]])
print(y.ndim)
yis a 2D array with 2 rows and 4 columns.- The
ndimattribute in NumPy returns the number of dimensions of the array.
Since y is a 2D array, y.ndim will return 2.
Answer: (B) 2.
Correct Answer: B) 2