Boolean Data TypeΒΆ

In computer programming, a boolean data type is a data type that can have one of two values which are usually denoted as true and false. In Python the syntax for these two values are True and False. These two values are built into the Python programming language and are of type boolean or bool for short.

Create a new Jupyter Notebook and call it booleans_comparison_logical_operators. Type out the code as you read and go through this. Play around with code because it will help you to learn!

True
True
False
False
type(True)
bool
type(False)
bool

They are case sensitive. If you try writing for example, true, or FALSE, or some variation you will get an error.

So why is this important? Well, often programs are made up of lots of tiny decisions that depend on various outcomes. For example, you might want to perform some logic if something is True or perform different logic if something is False. This is why boolean data types are so important.

You may be wondering how does something evaluate to True or False? To start learning more about this we are going to introduce the Python comparision operators.