Variables & Data Types

Booleans

A boolean can only be one of two values:

True
or
False
.

Creating Booleans

is_sunny = True
is_raining = False

Comparison Operators

Comparisons return boolean values:

OperatorMeaningExample
==
Equal to
5 == 5
→ True
!=
Not equal
5 != 3
→ True
>
Greater than
5 > 3
→ True
<
Less than
5 < 3
→ False
>=
Greater or equal
5 >= 5
→ True
<=
Less or equal
5 <= 3
→ False

Logical Operators

Combine boolean expressions:

  • and
    : Both must be True
  • or
    : At least one must be True
  • not
    : Reverses the value
Visualizer
True
assigned to
True
is_adult

Interactive Visualization

python
Loading...
Output
Run execution to see output...