🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: NumPy: all 10 questions

Quiz: NumPy · Question 7 of 10

What does this print? (code)

What does this print?

import numpy as np
marks = np.array([55, 82, 40, 91])
print(np.where(marks >= 50, "pass", "fail"))
  1. A.['fail' 'pass' 'pass' 'pass']
  2. B.[True True False True]
  3. C.['pass' 'pass' 'fail' 'pass']
  4. D.['pass' 'fail']
Answer & explanation

Correct answer: ['pass' 'pass' 'fail' 'pass']

np.where picks "pass" where the condition is True, otherwise "fail".

Can you get the rest right without peeking?

Take the timed Quiz: NumPy quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →