← 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"))
- A.['fail' 'pass' 'pass' 'pass']
- B.[True True False True]
- C.['pass' 'pass' 'fail' 'pass']
- 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 →