Understanding a Boolean formula.
Creating a Boolean Formula
Boolean operators are used to create conditions that require a logical relationship between two or more values. Conditions that use Boolean operators are called Boolean expressions.
A and B means that both A and B must be true for the condition to be satisfied (to return a True value).
A or B means that either A or B (or both) must be true for the condition to be satisfied (to return a True value).
Examples of Boolean Operators
Several useful examples of Boolean operators include the following:
And
Or
Not
The AND Operator
The And operator joins the value of x and y. The And operator takes two expressions that evaluate to a Boolean. The expression evaluates True only if both x and y are true. All other combinations result in a value of False.
Value of x | Value of y | x and y |
---|---|---|
True | True | True |
True | False | False |
False | True | False |
False | False | False |
The OR Operator
The Or operator takes two expressions that evaluate to a Boolean. If either expression evaluates True, the operator returns True. If both expressions evaluate False, the operator returns False.
Value of x | Value of y | x and y |
---|---|---|
True | True | True |
True | False | True |
False | True | True |
False | False | False |
The NOT Operator
The NOT operator reverses the True or False value of x.
Value of x | Not x |
---|---|
True | False |
False | True |