1. Home
  2. Data Science
  3. NumPy
  4. What does the ndim attribute of a NumPy array return?

Added 2 Nov 2026

What does the ndim attribute of a NumPy array return?

  1. The total number of elements
  2. The number of dimensions Correct answer
  3. The data type of the array
  4. The size of each element in bytes

Correct answer

B. The number of dimensions

14 views

MCQSEXAM

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

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More NumPy MCQs

Practise all NumPy MCQs

Similar MCQs