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: true and 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?

  • To determine validity. For example, we want to know whether a meme is viral. If it’s been viewed more than 50 million times in less than a week, we’d say that it’s true that it went viral.
  • To make decisions. For example, if I get an email, the program checks that the email is new and it displays at the top of my inbox.

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 true and false to represent boolean values, it’s important to remember that they are different from the strings 'true' and 'false'.


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 true to false.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?