Module 03 • Decisions
MakingDecisions
ManoBot has reached a traffic signal. Should she move, wait or stop? Python can make choices by checking conditions.
Watch
Mano reaches a decision point.
Watch how conditions allow Python to choose different instructions depending on what ManoBot sees.
The Big Idea
Python asksa question.
A condition can be either true or false. Python checks the condition and follows the correct path.
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.
ManoCity Junction
What will ManoBot do?
Ready to decide?
Select a traffic signal, then press Run Code.
Three Paths
if, elifand else.
Check First
Python checks the first condition.
Check Another
If the first condition was false, Python can check another.
Everything Else
If none of the earlier conditions were true, Python uses 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