Boolean Algebra?

>>> True and 1
This just doesn’t make any sense?

Python docs:

Note that neither and nor or restrict the value and type they return to False and True , but rather return the last evaluated argument. […]

1 Like

Actually, why would that not make sense? Think about it, why would the word “True” be the only thing in the universe that could contain the concept of “truth”? Couldn’t you assign “truth” to anything that is deemed “positive”? Here’s how:

In a computer you really only have 1s and 0s because everything in a computer is just a switch. When you give the switch electricity it turns “on” and becomes 1. When you remove the electricity, the switch turns off and the switch becomes 0.

This makes sense because “turn on the electric” means you give the switch power, juice, energy. It is now positive, like turning on a water hose, so that would mean the presence of energy and flow, so it’s 1. It also makes sense for the inverse, 0, because I turn off the hose, turn off the switch, and now there is nothing.

In the computer then, everything from numbers to decisions, to memory storage, to processing operations, all happen with just switches turning electricity on and off, making 1s and 0s happen. These switches don’t really have any meaning, but we give them meaning and just decide they mean, numbers, True, False, graphics, letters, and code instructions.

So, in Python, they just decided a more high level concept: Many things can be “true” or “false” than just 0 and 1.