Skip to content
KinPilot™Learn & Explore
Menu

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.

D12 visual explanationThe fictional bridge is open. The condition checks whether it is open. Yes uses the bridge; no uses the path around. Exactly one branch executes, giving route bridge. This chooses an action, not a category for sorting objects.A yes/no condition chooses one routeBridge signal: OPENIs itopen?YesNoUse bridgeGo aroundOnly one route runs; the other route is skipped.

In the diagramA yes/no condition chooses one routeBridge signal: OPENIs itopen?YesNoUse bridgeGo aroundOnly one route runs; the other route is skipped.

The open bridge makes the condition yes, selecting only the bridge route.

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
← Grades K–2 topics