2 of 1 ·Decision trees

Lesson 2 · Computational Thinking
Mapping choices and outcomes.
Conditions & Decisions
A condition is a question with a yes or no answer. If it is raining, take an umbrella. Draw one question and two possible actions before making a bigger tree.
Click to zoomWhen one question isn't enoughA single IF handles a single question. But real decisions stack up.
Should I cycle to school? Well — is it raining? If no, is the cycle working? If yes, is there time?
Each answer leads to the next question, and eventually to an outcome. Draw that out and you get a decision tree: questions at the branches, outcomes at the ends.
Click to zoomHow to read a treeIn the yes/no decision trees we are making today:
Start at the top. Answer one question and follow its path. Stop when you reach an ending. Other kinds of decision tree can have more than two choices.
हिंदी में: ऊपर के सवाल से शुरू करें। हाँ या नहीं वाला रास्ता चुनें। अगला सवाल हो तो उसका जवाब दें; काम बताया हो तो वहीं रुकें।
7 more parts in this lesson
Walkthroughs, code labs, mini-games and the checkpoint quiz unlock when you buy the course.