0
0
Pythonprogramming~5 mins

Comparison operators in Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the == operator do in Python?
The == operator checks if two values are equal. It returns True if they are the same, and False if they are different.
Click to reveal answer
beginner
What is the difference between == and != operators?
== checks if two values are equal, while != checks if two values are not equal. != returns True if values differ.
Click to reveal answer
beginner
How do you check if one number is greater than another in Python?
Use the > operator. For example, 5 > 3 returns True because 5 is greater than 3.
Click to reveal answer
beginner
What does the <= operator mean?
The <= operator means 'less than or equal to'. It returns True if the left value is smaller than or exactly equal to the right value.
Click to reveal answer
intermediate
Can comparison operators be used with strings in Python? How?
Yes, comparison operators can compare strings based on alphabetical order. For example, 'apple' < 'banana' returns True because 'apple' comes before 'banana'.
Click to reveal answer
What will 7 == 7 return in Python?
AFalse
BTrue
C7
DError
Which operator checks if two values are NOT equal?
A!=
B==
C>
D<=
What does 5 <= 5 evaluate to?
AFalse
B5
CTrue
DError
Which comparison operator means 'greater than'?
A>
B==
C<
D!=
What will 'cat' < 'dog' return?
AFalse
BDepends on Python version
CError
DTrue
Explain how to use comparison operators to compare two numbers in Python.
Think about checking if numbers are equal, different, or which one is bigger.
You got /6 concepts.
    Describe how comparison operators work with strings in Python.
    Strings are compared like words in a dictionary.
    You got /4 concepts.