True and False
True and False are Python's two boolean values: they answer yes or no to a question.
Used in 111 lessons of the course, from 00.02.
A boolean (bool) can only be True or False. Both are written with a capital first letter; lowercase true does not exist, and Python reads it as an ordinary name.
You get them in two ways: you write them yourself, or they come out of a comparison like 3 > 2. That is why if and while use them to decide what to do.
In the course you will see them as flags, switches that turn an option on. In the line from lesson 00.02, capture_output=True tells subprocess.run to keep the program's output, and text=True asks for it as text instead of bytes. Passing True or False as a keyword argument is the usual way to turn a behavior on or off.
active = True
They are named this way because they have only two states, and the option's name already says what it switches.
Reach for it when: you need to store or pass a yes-or-no answer, like switching an option on or remembering whether something held.
Examples
Common mistake
ready = true print(ready)
Why: Python is case-sensitive. `true` is not a value, so Python looks it up as a name and cannot find it.
How to write it: Write it with a capital first letter: True.
Common mistake
flag = "False"
if flag:
print("on")
else:
print("off")Why: `"False"` is a string holding text, not the boolean. A non-empty string counts as true in an `if`.
How to write it: Remove the quotes: flag = False.
