Lesson 6 of 10

Yes or no paths

A program asks a yes or no question, then picks a path.

Scene 1 of 5

A program can pick a path. It asks a yes or no question.

A fork: sunny? Yes goes to park. No goes to books. This time: yes, to park.
Scene 1 of 5

Tip

if goes one way when true, else goes the other way.

Library

All about choosing

What is a condition?

A condition is a yes or no question. The answer is true or false.

if

if checks the question. When the answer is true, the program takes that path.

else

else is the other path. The program takes it when the answer is false.

Asking about numbers

You can compare numbers too. age >= 7 asks, "Is age 7 or more?"

Yes
true
No
false
Compare
age >= 7

Words to know

  • if = when this is true
  • else = otherwise
  • >= = this much or more