निम्नलिखित कोड का परिणाम क्या है ?
What is the output of the following code ?
import numpy as np
a = np.array([[1,2,3]])
print(a.ndim)
A)
B)
C)
D)
Explanation:
The correct answer is:
(B) 2
Explanation:
- In the code,
a
is a NumPy array created with the shape[[1, 2, 3]]
, which represents a 2D array with 1 row and 3 columns. a.ndim
returns the number of dimensions of the array.- Since
a
is a 2D array (1 row and 3 columns),a.ndim
will be 2.
Output:
(B) 2