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

Flowcharts that choose

Week 4 · Unit 7.1: Block it out · 3 lessons
1

A fork in the flowchart

Computing 7: Unit 7.1, pp. 8–43
GoalExplain selection, use a decision diamond with yes and no branches, and trace a flowchart that makes a choice.
New words
selection · a point in a program where a choice is made between two or more pathscondition · a question that is either true or false, such as age < 8sequence · steps that are carried out one after the other, in orderdecision symbol · a diamond in a flowchart that holds a condition and has two ways out, yes and no
Explanation

A program with only a sequence does the same steps every time. Many programs have to make a choice, and that is called selection. A selection starts with a condition, which is a question that can only be answered true or false. In a flowchart the condition goes in a diamond. The diamond has two arrows out of it: one for yes (true) and one for no (false). The program follows only one of them. Afterwards, the paths can join again before the stop. To trace a flowchart, choose an input, answer the question and follow the right arrow.

StartINPUT ageage < 8?yesnoOUTPUT "Shallow pool"OUTPUT "Main pool"End
Worked examples
Age typedage < 8?Output
6yesShallow pool
8noMain pool
30noMain pool
This is the pool flowchart traced with three inputs. The condition is age < 8. Each input follows exactly one path.
StartINPUT ageage < 12?yesnoprice = 5price = 10OUTPUT priceEnd
A branch can hold a process box as well as an output. Here the price is chosen first. Both branches join again, and then the price is shown. For age 9 the output is 5, and for age 12 it is 10.
ConstructWhat it doesIn the ticket flowchart
sequencesteps one after anotherINPUT age, then price, then OUTPUT price
selectionchooses one of two pathsthe diamond: age < 12?
Every flowchart is built from two constructs. Which one is a step in a row, and which is a choice? Look at the tickets flowchart.
Class activity

Choose a path (no computer): draw a large diamond on a sheet and write the condition ‘Is the number less than 10?’ in it. Draw a yes arrow to the left and a no arrow to the right. On the left write ‘hop on one foot’ and on the right ‘clap twice’. A partner thinks of a number and tells you. You put a coin on the diamond and move it along the correct arrow, and do the action. Try the numbers 4, 10 and 25. Then make your own diamond with a different question. If you have a computer or tablet, draw your flowchart in a drawing program.

Practice
1
Trace the flowchart with 14 items and then with 10 items. What is output each time?
StartINPUT itemsitems > 10?yesnoOUTPUT "Use a trolley"OUTPUT "Use a basket"End
2
Mia’s flowchart should say ‘Too hot’ for temperatures over 35. Find the mistake and say how to fix it.
StartINPUT temptemp > 35?yesnoOUTPUT "Comfortable"OUTPUT "Too hot"End
3
Draw a flowchart for this: the user enters the number of players. If there are at least 11 it outputs ‘Match can start’; otherwise it outputs ‘Need more players’.
4
In the ticket flowchart in example 2, name the sequence part and the selection part. Why can the two branches join again before OUTPUT price?