5.9. Logical operators#
We already learned Python’s logical operators not, or, and and. Unfortunately, these operators work only on booleans, not on arrays of booleans. However, NumPy provides equivalent operators:
Python’s operator on |
NumPy’s equivalent operator for arrays of |
|---|---|
|
|
|
|
|
|
Fig. 5.8 illustrates the behaviour of each operator.
Fig. 5.8 Correspondence between logical operations on bool and ndarray.#