Python · Stage 1 · Storing Information · Lesson 11 of 50

True and False

Represent yes-or-no information with Python’s boolean values.

Imagine a light switch. It can be on or off. A boolean stores the same kind of two-choice information.

is_logged_in = True
Line-by-line explanation
  1. is_logged_in names a yes-or-no fact.
  2. = stores a value.
  3. True means the answer is yes.
has_permission = False
Line-by-line explanation
  1. has_permission names another fact.
  2. False means the answer is no.

True and False begin with capital letters and have no quotes. "True" would be text instead.