Skip to content
S3U
Login Create Account
All video lessons

Science / Grades 3-6

Programming basics: choose a branch

Learning goal: Use an IF/ELSE flowchart and test the exact boundary of a condition.

Before you start: Compare whole numbers and follow one instruction at a time.

Read or print this lesson What to practice

Paper Program Studio: session 3

Next: your worksheet

Programming Basics: Choose One Branch

Continue to worksheet
Not started 0s active

Checking sign-in...

Read the transcript

Video transcript and practice. Reading or printing does not count as playback time or an assessed grade.

1. A program can choose a path

Video: 0:00

Video illustration: A program can choose a path. The spoken explanation follows.
A program can choose a path: video illustration

Programs can choose what to do by checking a condition. A condition is a question with a true or false answer. Our example asks whether points is at least five. That answer selects one of two paths through the drawing.

2. Read the comparison carefully

Video: 0:17

Video illustration: Read the comparison carefully. The spoken explanation follows.
Read the comparison carefully: video illustration

The comparison symbol means greater than or equal to. We can read it as at least five. Six meets that rule, and so does five itself. Four does not. The equal part is small on the page but important to the answer.

3. Follow the true path

Video: 0:36

Video illustration: Follow the true path. The spoken explanation follows.
Follow the true path: video illustration

In our pseudocode, if points is at least five, the program shows the word ready. This is the true branch. Start at the condition and follow the arrow labeled true. It leads to one display action, not to both actions.

4. Follow the other path

Video: 0:54

Video illustration: Follow the other path. The spoken explanation follows.
Follow the other path: video illustration

If the condition is false, the program shows practice instead. That is the else branch. With four points, follow the false arrow. The program has not become moody; it is following the rule we wrote for that value.

5. Pause at the boundary

Video: 1:11

Video illustration: Pause at the boundary. The spoken explanation follows.
Pause at the boundary: video illustration

Pause and predict what appears when points is exactly five. This value sits right on the boundary between the two outcomes. Do not guess from the size of the number. Read every part of the comparison, including the equal sign.

6. Equality belongs on this side

Video: 1:29

Video illustration: Equality belongs on this side. The spoken explanation follows.
Equality belongs on this side: video illustration

Five is equal to five, so greater than or equal to is true. The program shows ready. If we had written only greater than five, this same input would take the other path. Testing the boundary helps reveal that kind of mistake.

7. A branch can remain unused

Video: 1:48

Video illustration: A branch can remain unused. The spoken explanation follows.
A branch can remain unused: video illustration

Fun fact: a program can contain a branch that a particular run never uses. In this if and else example, only one branch runs for each check. Trying only large point values would leave the practice branch untested. Different inputs help explore different paths.

8. Check both sides of the rule

Video: 2:09

Video illustration: Check both sides of the rule. The spoken explanation follows.
Check both sides of the rule: video illustration

Trace four, five, and eight points before moving on. For each value, say whether the condition is true and which word appears. Then continue to the worksheet. The words are part of a fictional example, not a rule that changes your actual learning grade.

Show your understanding

You can point, explain aloud, draw or write.

  • Choose the IF or ELSE branch by testing the condition.
  • Test the exact boundary and explain why only the selected branch runs in the example.

Try it yourself

Pause and trace the instructions before checking the answer.

Continue to the matching worksheet. These examples use teaching pseudocode, not code to paste into a computer.

Next: your worksheet

Programming Basics: Choose One Branch

https://s3u.com/sc470

Lesson: https://s3u.com/lessons/programming-choices