Python · Stage 3 – Making Decisions · Lesson 19 of 50

What Is Control Flow?

Understand how a program can choose which instruction runs next.

print("First")
print("Second")
Line-by-line explanation
  1. The first line runs first.
  2. The second line runs next.
  3. The output follows that same order.

A decision can change that path. Think of a road junction: the program chooses one road based on a yes-or-no condition.

Tiny Practice

Put these messages in the order you want them to run.

Starter template

print("Step 1")
print("Step 2")
Line-by-line explanation
  1. The first line runs before the second.
  2. Both lines display text.
Hint
  1. Read from top to bottom.
  2. Move a line if you want it earlier.
  3. Run the file to confirm.
Show Solution
print("Step 1")
print("Step 2")
Line-by-line explanation
  1. Step 1 is displayed first.
  2. Step 2 is displayed second.
  3. This is straight-line control flow.