Boolean operators
In real-world settings, very few things work in a one-to-one fashion, for example, flipping on a single switch to power on a machine. Even a thing as simple as turning on a light often requires a person to flip two switches! In other words, to turn things on or off, multiple conditions may need to be satisfied. For example, an output as simple as a lightbulb may need at least two switches to be on to power the bulb. Essentially, all this can be boiled down to three basic Boolean operators, which are as follows:
- AND
- OR
- NOT
The basic operators
A Boolean operator is a word that signals an operation on one or more conditions. For many, this explanation may not make a lot of sense, and the best way to demonstrate it is with a few examples. An easy way to understand operators is to examine a couple of sentences.
The AND operator
The AND operator signals that all conditions must be true for the final output to be true. For example, consider...