ManoCity
LearningPython EssentialsMaking Decisions

Module 03 • Decisions

MakingDecisions

ManoBot has reached a traffic signal. Should she move, wait or stop? Python can make choices by checking conditions.

15 MinutesBeginner1 VideoInteractive Decision

Watch

Mano reaches a decision point.

Watch how conditions allow Python to choose different instructions depending on what ManoBot sees.

Finished watching? Now make the decision yourself.

The Big Idea

Python asksa question.

A condition can be either true or false. Python checks the condition and follows the correct path.

light == "green" ?

True

GO

False

Check next

Try It

Choose the signal.Then run the decision.

Watch Python test each condition until it finds the correct action.

traffic_light.py
1light = "red"
2
3if light == "green":
4action = "GO"
5elif light == "yellow":
6action = "GET READY"
7else:
8action = "STOP"

ManoCity Junction

What will ManoBot do?

🤖

Ready to decide?

Select a traffic signal, then press Run Code.

Three Paths

if, elifand else.

if

Check First

Python checks the first condition.

if light == "green":
elif

Check Another

If the first condition was false, Python can check another.

elif light == "yellow":
else

Everything Else

If none of the earlier conditions were true, Python uses else.

else:

Mini Challenge

An obstacle is 8 cm ahead.

Read the code and decide what ManoBot should do.

distance = 8


if distance > 10:

print("Move forward")

else:

print("Stop")

Remember This

Conditions let Pythonchoose what happens next.

if → first conditionelif → another conditionelse → everything else