Skip to content

Making Decisions: Conditions

Beginning of the lesson

Making Decisions: Conditions

How programs choose between two paths

Big Idea: Programs can make choices. They ask a yes-or-no question called a condition. If the answer is true, the program does one thing. If the answer is false, it does something else. This is the if / else idea.
By the end you will be able to:
  • say what a condition is,
  • explain how if and else pick a path,
  • read a simple decision-flow diagram,
  • write a decision as an "If … then … else …" sentence.

1. What is a condition?

A condition is a question that can only be answered with true (yes) or false (no). There is no "maybe".

You use conditions every day, even without noticing:

  • "Is it raining?" → true or false
  • "Is my homework finished?" → true or false
  • "Is the traffic light green?" → true or false

A program checks the condition, gets a true or false answer, and then chooses what to do next.

2. The "if it rains" idea

Think about getting ready to go outside. In your head you say:

If it is raining, then take an umbrella.
Otherwise (else), wear sunglasses.

That is exactly how a program decides! The condition is "Is it raining?". The if part runs only when the answer is true. The else part runs only when the answer is false.

Notice something important: only one path runs. You never take an umbrella and wear sunglasses at the same time. The program picks one path and skips the other.

Continue this lesson on YourAIZone

The full lesson has the complete explanation, worked examples, common mistakes, tests with instant checking and an AI tutor. Start right away as a guest, or create an account to keep your progress.

In the full lesson

  • The complete explanation
  • Worked examples
  • Common mistakes and how to avoid them
  • Test questions: 15
  • AI tutor that answers questions about the topic
  • Progress tracking for students, parents and teachers