Boolean values can only have values of true or false.
Boolean Expressions
Sometimes a programmer would like a statement, or group of statements to execute only if certain conditions are true.
There may be a different statement, or group of statements that are to be executed when the condition is false.
An expression that can be evaluated to true or false is called a Boolean expression. (Named after a mathematician named Boole.)
Examples of Boolean Expressions: (X and Y are variables)
x == 5 |
(True if x has a value equal to 5) |
x > y |
(True if x is greater than y; example x is 7, Y is 3) |
x < y |
(True if x is less than y; example X is 2, y is 2.5) |
x != y |
(True if x is not equal to y; example x is 5, y is 6) |
x >= y |
(x is greater than or equal to y; example x is 4, y is 3 or 4) |
x <= y |
(x is less than or equal to y; example x is 4, y is 4 or 5) |