Skip to content
Quiz · NumPy and pandas · lesson 4 of 12

Quiz — sums over a boolean mask

What does this program print?

Python
import numpy as np

a = np.array([4, -1, 7, 0, -3])
print(a[a > 0].sum(), (a > 0).sum())

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way