What is a boolean?

A boolean is a variable that is either True or False. We say the datatype of a variable can be booelan.

You can think of it like a light switch, its either on or off. Its based on the smallest unit in a computer, a bit. A bit is a value that is either 0 (False) or 1 (True). You can view a bit as synonym of boolean for now.

Related Course:


In Python you do not need to explicitly data types. To use one, assign a boolean value to a variable.

To define a boolean in Python we simply type:

light = False

If you want to set it to on, you would type:

light = True

The value of a variable can be shown like so:


You can also type:

light = 0
which is equivalent to False. Likewise you can write
light = 1

which is the same as True.

Download exercises