Generating Boolean Values with Comparison Operators
By using comparison operators
, you can generate Boolean values through comparison of different values or variables.
What are the comparison operators?
In Python, you can use the following comparison operators:
-
Equality
(==
): Compares if the values on both sides of the operator are equal. -
Inequality
(!=
): Compares if the values on both sides of the operator are different. -
Relational Comparison
(>
,<
,>=
,<=
): Compares the size of the values on both sides of the operator.
Example of using comparison operators
x = 5 y = 3 # Equality print(x == y) # False # Inequality print(x != y) # True # Relational Comparison print(x > y) # True print(x < y) # False
Mission
0 / 1
Which of the following cases is True?
5 == 3
5 < 3
5 != 3
5 <= 3
Guidelines
AI Tutor
Publish
Design
Upload
Notes
Favorites
Help
Code Editor
Run
Generate
Execution Result