Boolean Operations
Python provides operators to combine the values using the standard concepts of "and", "or", and "not". These operators are expressed using the words and…
and, or, not
Python provides operators to combine the values using the standard concepts of "and", "or", and "not". These operators are expressed using the words and, or, and not.| X | Y | X or Y |
|---|---|---|
| True | True | True |
| True | False | True |
| False | True | True |
| False | False | False |
| X | Y | X and Y |
|---|---|---|
| True | True | True |
| True | False | False |
| False | True | False |
| False | False | False |
| X | not X |
|---|---|
| True | False |
| False | True |
Reading the tables the short way: and is True only when BOTH sides are True. or is False only when BOTH sides are False. not flips the value.