1. Home
  2. Data Science
  3. NumPy
  4. For a = np.array([10, 20, 30, 40]), what does a[[0, 2]]…

Added 2 Nov 2026

For a = np.array([10, 20, 30, 40]), what does a[[0, 2]] return?

  1. array([10, 20, 30])
  2. array([10, 30]) Correct answer
  3. array([10, 20])
  4. array([20, 40])

Correct answer

B. array([10, 30])

15 views

MCQSEXAM

Explanation

Indexing with a list is fancy indexing: it picks elements 0 and 2. Unlike basic slicing, fancy indexing returns a copy, not a view.

Reference

Asked in: Data Science Interviews

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