Menu

A Boolean is a data type that can hold only one of two values: True or False. Nothing else fits — not a number, not a word. It is the right choice when something can only ever be in one of two states, such as whether a library book has been returned or whether a player is still in a game.

True and False are keywords

In Python, True and False are Boolean keywords: the language already recognises them and treats them as values in their own right, not as pieces of text. Both start with a capital letter, and that spelling matters — writing true in lowercase gives a name Python does not know, so the program stops with an error. A Boolean also never holds words such as yes or no, or the whole numbers 1 and 0; its only two values are True and False.

Quotes or no quotes

This is where a Boolean literal differs from a string literal. A string literal is text, so it is written inside quote marks, and the quotes tell Python that the characters are data rather than code. A Boolean literal is written bare, because the keyword on its own is already a complete value — adding quotes would turn it into text and change its type.

Written asData typeWhat it holds
TrueBooleanthe true value, one of only two possible values
"True"stringfour characters of text: T, r, u and e
music_playing = False
reply = "False"  # text, not a Boolean
print(music_playing)
print(reply)

Output:

False
False

Here music_playing stores one of the two Boolean values, while reply stores text made of four characters. They look similar when printed, but they are different data types holding different things, which is exactly why one is quoted and the other is not.

Practise this