Intro to Programming: Booleans

Published on: June 1, 2015

Tags: programming and intro-programming

Explaination

As you’ve probably heard, computers think in 1s and 0s. There is no middle ground, there’s no 0.5, no 1.1, no 1 and 0 at the same time. 1 or 0, that’s all they’ve got. It turns out, 1s and 0s are pretty powerful.

Humans have the same concepts as 1s and 0s, we just call them different things - True or False. For the sake of this post (and all the computers in the world) we will assume something is either entirely True, or entirely False. There is no middle ground, no maybe, no white lies. Something is either True or False. Something which is either True or False is known as a Boolean, after George Boole.

“The sky is blue” is True.

For me, “I am female” is also True, while “I am very tall” is False.

In general, computers have no notion of time. There is only the now, no past, no future. A computer doesn’t know what it will be doing in a few minutes (that depends on what you tell it to do, and on what it’s doing now), and it isn’t interested in what it was doing an hour ago. So when computers decide if something is True or False, they have to decide at that moment is the thing True or False?

“I am very tall” is False right now. It’s possible (though unlikely) I’ll have a giant growth spurt and be very tall in the future. That doesn’t matter, we are not interested in what will happen, only that I am not very tall right now.

“Caramel is my favorite ice cream flavor” is presently True. But it might change tomorrow when I try the best chocolate ice cream in the world. Certainly it has changed from my childhood favorite (Rainbow Sherbet). Again, we only focus on my current favorite flavor.

Exercises

Ok, now it’s your turn. Decide if each of these statements is True or False for you at the current moment.

Think about your every day life, and come up with at least five more examples of when things are True or False.

Thanks for submitting your examples!

comments powered by Disqus