1. Home
  2. Data Science
  3. NumPy
  4. For a = np.array([3, 8, 1, 9]), what does a[a > 5] return?

Added 2 Nov 2026

For a = np.array([3, 8, 1, 9]), what does a[a > 5] return?

  1. array([3, 1])
  2. array([8, 9]) Correct answer
  3. array([1, 3])
  4. array([False, True, False, True])

Correct answer

B. array([8, 9])

16 views

MCQSEXAM

Explanation

Boolean indexing uses the mask a > 5 to select matching elements. The mask itself is the True/False array, which is a common confusion.

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