This next data type has a special importance to computing. Boolean values represent the logical ideas of true and false.
Booleans, unlike numbers or strings, only have two values:
false. The term boolean comes from the inventor of a specific form of logic, George Boole. Logic is important to computer science because it is an early attempt at translating the human capacity for reason to computers.
So, what do we use booleans for?
Because booleans act as binary opposites, we can think of them in a myriad of ways, like on and off, yes and no, sometimes even 1 and 0.
While we use the words
false to represent boolean values, it’s important to remember that they are different from the strings
Programmers first were able to illustrate the idea of binary logic through turning on and off electric circuits, where on equaled
true and off equaled
false. In fact, the relationship between electricity and logic is the basis for digitization!
Flip the switch to see the scene change from day to night and watch the lights turn on and off. Notice how the variable
LightsOn stays the same, but its value changes from