When designing programs, there are often points where a condition needs to be tested in order to make a decision. Conditions are formed using Boolean logic.
programSequences of instructions for a computer. use simple comparisons to help make decisions. Boolean logicA form of logical algebra which works only with two values, true or false. is a form of algebra where all valueA numerical amount denoted by a specific term, eg the value of x is 10. are either true or false. These values of true and false are used to test the conditionIn computing, this is a statement or sum that is either true or false. A computation depends on whether a condition equates to true or false. that selectionA decision within a computer program when the program decides to move on based on the results of an event. and iterationIn computer programming, this is a single pass through a set of instructions. are based around.
Boolean logic uses algebra and algebraic expressions. Use these expressions in algorithms and programs:
Expression
Boolean equivalent
Equals
=
Greater than
>
Less than
<
Greater than or equal to
>=
Less than or equal to
<=
Does not equal
<>
And
AND
Or
OR
Not
NOT
Expression
Equals
Boolean equivalent
=
Expression
Greater than
Boolean equivalent
>
Expression
Less than
Boolean equivalent
<
Expression
Greater than or equal to
Boolean equivalent
>=
Expression
Less than or equal to
Boolean equivalent
<=
Expression
Does not equal
Boolean equivalent
<>
Expression
And
Boolean equivalent
AND
Expression
Or
Boolean equivalent
OR
Expression
Not
Boolean equivalent
NOT
Most programming languages use these equivalent Boolean expressions. However, some, such as PythonA high-level programming language., have slightly different equivalents: