4.5. Standard Type Operators
4.5.1. Value Comparison
Comparison operators are used to determine equality of two data values between members of the same type. These comparison operators are supported for all built-in types. Comparisons yield true or false values, based on the validity of the comparison expression. Python chooses to interpret these values as the plain integers 0 and 1 for false and true, respectively, meaning that each comparison will result in one of those two possible values. A list of Python's value comparison operators is given in Table 4.1.
operator | function |
---|---|
expr1 < expr2 | expr1 is less than expr2 |
expr1 > expr2 | expr1 is greater than expr2 |
expr1 <= expr2 | expr1 is less than or equal ... |
Get Core Python Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.