Flow Control Part One - Hsanokklis/2023-2024-Tech-journal GitHub Wiki
Flowchart
Boolean Values
Boolean Values have two values:
- True
- False
Info on Booleans:
- The word Boolean is always capitalized
- When writing Booleans in code as True or False, the true/false have to be capitalized
Comparison Operators
- Comparison operators compare two values and evaluate down to a single Boolean value
Python will evaluate a number (int) and a number (str) to be false ie 42 == '42' will be false
Boolean Operators
There are 3 Boolean operators
- and
- or
- not
These evaluate expressions down to a Boolean value
Binary Boolean Operators
and/or operators always take two Boolean values, so they're considered binary operators. The operator evaluates an expression to True if both Boolean values are true, otherwise it evaluates to false.
Example of true
Example of False
Truth Table
Shows every possible result of a Boolean operator
The not Operator
- operates on only one Boolean value
- evaluates to opposite the Boolean value
Mixing Boolean and Comparison Operators
- the computer will evaluate the left Boolean first
- Python evaluates the not operators first, then the and and then the or ones.