What does 7 > 4 give?
COMPUTING AND DIGITAL LITERACY
This document was made by AI and there may be mistakes. If a question or answer looks wrong, use the Flag a mistake button to let Brett know so he can fix it.
This is how a program or a spreadsheet decides what to do. It gives a discount only if a total is over fifty dollars, by checking whether one value is bigger, smaller, or equal to another. Comparison operators are the decision makers in code, and almost every rule in an app or a spreadsheet is built from them.
Compare two numbers
Solution
5 > 3 -> True
5 < 3 -> False
5 == 5 -> True
5 != 5 -> False
Write the two values with the comparison between them, such as 5 > 3.
Ask the question the symbol asks: is 5 greater than 3? Yes, so True.
Remember == tests equality while a single = stores a value; they are different jobs.
Check a pass mark
Solution
score = 62
score >= 50 -> True
So the program prints 'Pass'.
Store the score: score = 62.
Test it against the pass mark with >=, meaning greater than or equal to.
62 >= 50 = True, so the program prints Pass.
What does 7 > 4 give?
What does 7 < 4 give?
What does 7 == 7 give?
What does 7 != 7 give?
What does 7 >= 7 give?
What does 7 <= 6 give?
What is the difference between = and ==?
Which operator should the test use to check whether a viewer's age is at least 18?
Maya scores 45 and the pass mark is 50. Her quiz app tests score >= 50. What does that test give?
What type of value does every comparison give?
Your score: 0 / 10
1. True
2. False
3. True
4. False
5. True
6. False
7. = stores a value; == tests whether two values are equal
8. >=
9. False
10. A boolean: True or False