Skip to main content

Lesson 2.1: Compare Two Values

A comparison checks the relationship between two values. Its result is always the Boolean value true or false.

Number comparisons include equal to, not equal to, less than, greater than, less than or equal to, and greater than or equal to. The comparison 8 > 5 is true. The comparison 8 = 5 is false.

Equal to is a question. Assignment is a command that stores a value. They do different jobs even when their symbols or blocks look similar.

Text can also be checked for equality. Capital letters matter, so Ready and ready are different text values. Keep both inputs the same type unless the lesson clearly says otherwise.

Guided practice

Print the result of 7 < 10, then predict and run 7 = 10 and 7 ≠ 10. Create a variable named level, set it to 3, and compare level >= 3.

Change level to 2 without changing the comparison. Use Step and explain why the result changes. The comparison reads the variable's current value each time it runs.

Loading the block workspace...

Ready to move on?

Only mark complete if you genuinely understand the material. Your progress will be saved in this browser.

Stuck on this lesson?

Ask about anything on this page. It can see which lesson you have open and which part you are reading.