...

/

Solution Review: Using Conditions on Arrays

Solution Review: Using Conditions on Arrays

Here we’ll discuss the solution to using conditions on arrays.

We'll cover the following...

Solution #

Press + to interact
import numpy as np
x = np.linspace(0, 2 * np.pi, 20)
y = np.sin(x)
arr1 = y[(y > 0.7) | (y < -0.5)]
arr2 = y[(y > -0.5) & (y < 0.7)]
print(arr1)
print('-----')
print(arr2)

Explanation

  • In line 3, we have ...