Selection

What is selection?

Selection is the programming structure through which a computer executes one or other set of instructions according to whether a particular condition is met. You can build selection into a sequence of instructions. This ability to do different things, depending on what happens as a program is running, makes programming a powerful tool. At the core of many educational games is a simple selection command: if the answer is right then give a reward, otherwise (else) say the answer is wrong. Selection statements can be “nested” inside one another, allowing more-complex sets of conditions to be used to determine what happens in a program.

An example of how selection can be used to start a script in Scratch.

An example of how selection can be used to start a script in Scratch.

Nested selection and repetition commands in Scratch, to model a clock.

Nested selection and repetition commands in Scratch, to model a clock.

Why is selection important?

In computer science, selection gives us the capacity to write programs that are interactive, responding to inputs and behaving differently each time they run. Selection is integral to programs controlling physical systems. With automatic sliding doors, if an input from the motion sensor above the doors is detected then the doors open, else they stay shut. With burglar alarms, if motion is detected then a siren sounds, else it remains on standby. Electric ovens heat to a desired temperature, thanks to selection within the control program: if the oven temperature is the same as the demand temperature, the oven stops heating up – else, it keeps heating.

What does selection look like in the Primary curriculum?

Selection in programming is referenced in the Key Stage 2 objective “use selection in programs.” However, prior to this, younger pupils develop an understanding of selection in the world around them. For example, EYFS pupils might see examples of selection in the rules of their environment: “If there are fewer than two people in the roleplay area then enter, else choose another activity.” Similarly, they see examples of selection in everyday language and the choices we make: “If it’s cold out I’ll wear my woolly hat, else I won’t.” Some programming languages aimed at Key Stage 1 offer simple selection commands. As pupils progress through Key Stage 2, they use increasingly complex forms of selection commands and even consider combining (nesting) these to achieve a required result. In addition, the conditions which the selection blocks use will become more complex. This might initially be the simple comparison of a single answer, but subsequently progress to several
variable values and the use of AND or OR operators. As pupils progress through Key Stage 2 and gain more experience using selection commands, they should have confidence in identifying, whilst planning an algorithm, which commands to use, and structure it accordingly.

3 - 5 years

Younger pupils often use selection statements: for example, “If you do not give me that toy, I will tell the teacher!” However, when it comes to computing, their experience of selection is limited. Simple programmable toys such as Bee-Bots provide no means at all by which pupils can incorporate selection, the focus instead being on adding commands in simple sequences. When controlling a friend as a ‘human robot’, a child might instruct them to open a door. “If the door is closed then open the door” is the implication here, but it’s unlikely to be explicitly stated in this detailed way.