Grades K–2 · Computing
How does a yes-or-no condition choose an instruction route?
A branch lets instructions take one of two routes. A yes-or-no condition makes the choice. Here the condition means that the crossing is open. The picture supplies the open or closed signal.
In the diagramA yes/no condition chooses one routeBridge signal: OPENIs itopen?YesNoUse bridgeGo aroundOnly one route runs; the other route is skipped.
The bridge is open in the picture. The condition is yes, so the traveler uses the bridge route. The route around is still drawn, but it is not used on that trip.
When the signal says closed, the condition is no. The traveler goes around instead. One condition selects one route; it does not tell the traveler to use both routes.
About this explanation
Starting knowledge: Recognize open and closed signals and follow a drawn route with adult support.
Sources
- Code.org — If-Else Statements