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?✗ Incorrect
== checks if two values are equal. Since 7 equals 7, it returns True.Which operator checks if two values are NOT equal?
✗ Incorrect
!= means 'not equal to' and returns True if values differ.What does
5 <= 5 evaluate to?✗ Incorrect
<= means 'less than or equal to'. Since 5 equals 5, it returns True.Which comparison operator means 'greater than'?
✗ Incorrect
> means 'greater than'.What will
'cat' < 'dog' return?✗ Incorrect
Strings are compared alphabetically. 'cat' comes before 'dog', so it returns
True.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.