Skip main navigation

What is Selection?

What is selection and why is it important for programming? Read this article to find out
So far, the programs you’ve written have performed exactly the same task each time they are run. Selection involves your program asking a yes/no question, and using the answer to decide what to do next.

Here are a few examples of selection in everyday life.


When you leave for work each morning, you’ll probably take a look out of the window and ask yourself the question “Is it raining?”. If you’re really organised you may even take a look at the weather forecast and ask yourself the similar question “Is it likely to rain today?”.

Either way, you will use the answer to this question to decide what to do next. If the answer is “yes” you will grab your umbrella before you leave the house. If the answer is “no” you’ll leave it at home.

Grabbing an Umbrella


When playing a game of “Simon Says”, each time an instruction is given to you, you’ll ask yourself the question “Did the instruction start with the words ‘Simon says’?”. If the answer is “yes”, you will follow the instructions given to you, otherwise you will do nothing.


If you’ve ever painted by numbers, you’ll know that you’re constantly using information to decide what colour each section should be painted.

Paint by Numbers

The decisions made will look something like this:

  • if the number is 1 then paint the section red
  • if the number is 2 then paint the section blue
  • if the number is 3 then paint the section yellow
  • etc.

As in the previous examples, you are using the answer to a question (such as “Is the number 1?”) to select your next action.

This article is from the free online

Teaching Programming in Primary Schools

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now