1. Home
  2. Data Science
  3. NumPy
  4. What function is used to reshape a NumPy array?

Added 24 Feb 2024

What function is used to reshape a NumPy array?

  1. reshape() Correct answer
  2. resize()
  3. Both A and B
  4. None of the above

Correct answer

A. reshape()

13 views

MCQSEXAM

Explanation

reshape() gives an array a new shape without changing its data and returns the result: np.arange(6).reshape(2, 3). The total number of elements must stay the same.

resize() is different — it changes the array in place and may alter the number of elements.

Keep preparing with more Data Science MCQs on MCQsExam.com.

Doubts & discussion

Not sure why the answer is A? 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