Skip to content
Kids
KreerIQ

Conditions: if this, then that

Loading…

Free lesson

What you will learn

By the end, you can read an if / else block and predict what the program shows.

Sana's weather app has one tiny brain: if it is raining, show an umbrella; else, show sunglasses. That one little if is how games decide when you win, when a door opens and when a level ends.

Read the explanation

A condition is a question with a yes or no answer: is it raining? Is score > 10? An if block runs its lines only when the answer is yes (true). An else block runs when the answer is no (false). Exactly one of the two paths runs, never both.

  • > means greater than; < means less than.
  • if runs when the condition is true; else runs when it is false.
  • Only one path runs each time the program reaches the if.
All tracks