NEW Explore the Scratch Block Dictionary, tutorials, textbook, and classroom guides

Start learning →

Chapter 7: Comparisons & Boundary Checks

📌 What you will learn

Use <, =, and > operators accurately, including edge cases where two numbers are exactly equal.

Lesson goal & core concept

Prevent off-by-one bugs in score goals, borders, and timers.

Remember that "10 > 10" is false and "10 < 10" is false. Always test what happens right on the boundary number.

Step-by-step practice

Work through these steps in the Scratch editor, predicting each result before clicking the green flag.

  • Test whether a sprite crossed the right edge with <(x position) > (220)>.
  • Trigger victory when <(score) > (9)> for 10+ integer points.
  • Use <(hp) < (1)> instead of <(hp) = (0)> in case HP drops below zero.
  • Test boundary values (9, 10, 11) deliberately.
Chapter 7: Comparisons & Boundary Checks — Example
  1. When green flag clicked
  2. Forever
  3. If (x position) 200> then
  4. Say Finish line!

Try it: Announces the finish line as soon as x passes 200.

Mini challenge & next steps

Build a boundary guard that stops a sprite from walking past x = 210 or x = -210.

Scratch Learning Textbook Home Return to the full 4-stage curriculum overview. Learn more → Scratch Block Dictionary Look up any block used in this chapter. Learn more →

FAQ

How long should I spend on "Chapter 7: Comparisons & Boundary Checks"?

Aim for 15–20 minutes: read the concept, test the small example, modify one value to see what changes, and try the mini challenge.

This guide is provided for educational purposes. Scratch screens and terms may change over time, so please check the official Scratch website as well.