Concept Flow - Comparison operators
Start with two values
Apply comparison operator
Evaluate condition: True or False?
Use result in program
End
Comparison operators check how two values relate and give True or False as result.
a = 5 b = 3 result = a > b print(result)
| Step | Expression | Evaluation | Result |
|---|---|---|---|
| 1 | a = 5 | Assign 5 to a | a = 5 |
| 2 | b = 3 | Assign 3 to b | b = 3 |
| 3 | result = a > b | Is 5 greater than 3? | True |
| 4 | print(result) | Print the value of result | True |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|---|
| a | undefined | 5 | 5 | 5 | 5 |
| b | undefined | undefined | 3 | 3 | 3 |
| result | undefined | undefined | undefined | True | True |
Comparison operators compare two values and return True or False. Common operators: >, <, >=, <=, ==, != Used to check conditions in programs. Example: 5 > 3 is True. They do not return numbers, only boolean results.