There are four logical operators that work specifically on Boolean values:
- !—the NOT keyword (inverse of the resulting value):
>>> not (5 > 4)False
Jupyter interprets cells with an exclamation mark at the beginning as Terminal commands, so we can't use it there.
- |—the OR keyword (one or another, or both the values):
>>> (5 > 4) | (6 < 5)True
- &—the AND keyword (one and another value):
>>> (5 > 4) & (6 < 5)False
- ^—the XOR keyword (either one or another, but not both of the values):
>>> (5 > 4) ^ (5 < 6)False
The following are built-in functions that work on Boolean arrays:
- all(): Will return true only if all elements are True
- any(): Will return true if at least one element is True
Python has strong typing—it does ...