AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Software and smart devices

Week 6 · Unit 7.2: Decomposing problems · 3 lessons
3

Questions with two answers

Computing 7: Unit 7.2, pp. 44–81
GoalRead and draw a flowchart that uses selection to decide what to do.
New words
flowchart · a diagram of an algorithm made from shapes joined by arrowsselection · a choice in a program: the path depends on whether a question is true or falsedecision · the diamond in a flowchart that asks a yes or no questioncondition · the question or test inside a decision, such as “Is A pressed?”
Explanation

An algorithm is a list of precise steps. A flowchart draws an algorithm with shapes: ovals for start and stop, parallelograms for input and output, rectangles for processes and a diamond for a decision. The diamond asks a question that can only be answered yes (true) or no (false). Selection means the program chooses its path using the answer. With no selection, the steps are just a sequence, one after the other. On the micro:bit the question might be “Is button A pressed?” If yes, the outputs happen. If no, nothing happens. Always plan with a flowchart first. On paper it is quick to see whether the steps and the question are in a sensible order.

StartIs B pressed?yesnoshow a heartEnd
Worked examples
StartIs the logo touched?yesnoshow a starscroll the word HiEnd
This flowchart asks one question. If the touch logo is touched, the board shows a star and then scrolls the word Hi. If it is not touched, nothing happens.
SituationPath through the flowchartResult
logo is touchedstart, yes, show star, scroll Hi, enda star, then Hi
logo is not touchedstart, no, endnothing happens
Following a flowchart with a situation is called tracing it. For the flowchart above we can trace two situations and write down the path and the result.
SequenceSelection
shape that is newnonediamond
steps that happenall of themdepends on yes or no
examplescroll a word, show a pictureif a button is pressed, show a picture
A sequence has no choice: every step happens, in order. A selection has a diamond, and only one path is followed each time. The words in the flowchart say what the program does, not what the program looks like when typed.
Class activity

Human flowchart (no computer). Put three sheets of paper on the floor: the diamond “Is the card red?”, a “yes” sheet that says “clap twice” and a “no” sheet that says “stamp once”. An adult turns over ten playing cards one at a time and you follow the flowchart. Count the claps and the stamps. Then change the question to “Is the card a picture card?” and play again. What stayed the same, and what changed?

Practice
1
In this flowchart, what happens when button B is not pressed? What happens when it is pressed?
StartIs B pressed?yesnoscroll the word Stopshow a crossEnd
2
Draw a flowchart for this plan: if button A is pressed, show an arrow and then scroll the word Bus.
3
These steps are jumbled. The plan scrolls Done first and then shows a tick. Put the steps in the right order for the flowchart: (a) show a tick, (b) Start, (c) scroll Done, (d) Is A pressed?, (e) End.
LetterStep
ashow a tick
bStart
cscroll Done
dIs A pressed?
eEnd
4
Why is it a good idea to draw the flowchart before you write the program?