What does the ndim attribute of a NumPy array return?
-
A
The total number of elements
-
B
The number of dimensions
Correct answer
-
C
The data type of the array
-
D
The size of each element in bytes
Correct answer
B. The number of dimensions
14 views
Explanation
A matrix of shape (3, 4) has ndim = 2, size = 12 and an itemsize that depends on the dtype.
Reference
Asked in: Data Science Interviews, NTS
Doubts & discussion
Not sure why the answer is B? Ask here and get an explanation.
Ask a doubt about this MCQ