8. Boolean Variables¶
We can store true and false
Variables of this type are called logical or boolean
In Python, we can initialize variables of this type with
True
orFalse
Note that the T and F are capitalized, any other form generates a syntax error
8.1. Relational Operators¶
Operator |
Operation |
Mathematical equivalent symbol |
---|---|---|
== |
equal |
= |
> |
greater than |
> |
< |
less than |
< |
!= |
not equal |
<> |
>= |
greater or equal |
>= |
<= |
less or equal |
<= |
Note that the equality operator is two equals (
==
)
8.2. Examples:¶
Print output (drag lower right corner to resize)
|
Activity: CodeLens 8.2.1 (cl_l05_8a_en)
8.3. Important Example¶
>= or <= for equal values
Print output (drag lower right corner to resize)
|
Activity: CodeLens 8.3.1 (cl_l05_8b_en)
8.4. Example¶
We can use relational operators to initialize logical variables
Print output (drag lower right corner to resize)
|
Activity: CodeLens 8.4.1 (cl_l05_8c_en)
You have attempted 1 of 2 activities on this page