Recall & Review
beginner
What does the '==' operator do in Swift?
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.
Click to reveal answer
beginner
Which operator would you use to check if one number is greater than another?
Use the '>' operator to check if the value on the left is greater than the value on the right.
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 equal to the right value.
Click to reveal answer
beginner
How do comparison operators help in decision making in Swift?
Comparison operators return true or false, which helps the program decide which path to take, like choosing between options in an if statement.
Click to reveal answer
What will the expression '5 == 5' return in Swift?
✗ Incorrect
'5 == 5' checks if 5 is equal to 5, which is true.
Which operator checks if two values are NOT equal?
✗ Incorrect
'!=' means not equal.
What does '3 < 7' evaluate to?
✗ Incorrect
'3 < 7' means 3 is less than 7, which is true.
Which operator means 'greater than or equal to'?
✗ Incorrect
'>=' means greater than or equal to.
If 'a = 10' and 'b = 20', what does 'a != b' return?
✗ Incorrect
'a != b' checks if 10 is not equal to 20, which is true.
Explain how comparison operators work in Swift and give examples of at least three different operators.
Think about how you compare numbers or words in real life.
You got /3 concepts.
Describe a simple situation where you would use comparison operators in a Swift program.
Imagine choosing what to do based on a condition.
You got /3 concepts.