🧩Boolean
Also known as bool, True or False
A value that is only ever true or false. It works like a yes or no.
Think of it like
Think of it like a light switch. It is either on or off, and never in between.
Example
A music app keeps is_playing as a boolean. Press play and it becomes true; press pause and it becomes false.
Why it matters
Every choice a program makes comes down to a boolean. They are what an if checks.
Definition
Example code
python
>>> 5 > 3
True
>>> 5 == 3
FalseCommon mistake
Key takeaways
- 1Two values only. True or false, nothing else.
- 2From comparisons. Questions like a > b give a boolean.
- 3Drive decisions. Ifs and loops read them to choose.