2. Basic Types: Booleans
True or False
The first built-in Python type we will discuss are the booleans
In computer science, a boolean is a datatype that has one of two possible values: true or false. It is intended to represent the two truth values used in logic.
In Python, the booleans
Operator | Name | Usage | Returns |
Disjunction | Returns if either or or both are , otherwise . | ||
Conjunction | Returns if both and are , otherwise . | ||
Negation | Returns if is , otherwise . |
You might be wondering why there aren't more such operators. The answer is actually quite simple; they are not needed. These three operators can create any other boolean function when combined. In fact, even just and suffice for functional completeness. The logical operators can be combined with booleans to form logical expressions that result in booleans:
>>> True or False
|
True
|
>>> True and True
|
True
|
>>> not False
|
True
|
Or visit omptest.org if jou are taking an OMPT exam.