Skip main navigation

Sequence, Selection and Iteration

Discover the basic ideas behind computer programs.

Before we can go too deep into physical computing and creating your own projects, it’s a good idea to have a good grasp of the ideas behind computer programming.

This isn’t a full course on programming, there are lots of other courses you can do online and even on FutureLearn. xxx suggest course here? This gives you a basic understanding of the concepts behind programming. It will help you later on in the course when you’re creating.

All programming languages have the same concepts. Regardless of how they’re written, where they run and what they do, they all make use of these basic concepts

Sequence

Sequence is the order that commands go in. The order can really matter. Think of the instructions needed to make a cup of tea:

  1. Fill the kettle with water
  2. Turn the kettle on
  3. Put tea bag in cup
  4. Pour hot water into cup
  5. Stir
  6. Remove tea bag
  7. Add milk

If you did number 3 before 2 then that wouldn’t matter. However, if you did 2 after 1 then you won’t have enough water for your cup of tea.

This is a very simple example of sequence. We’ll highlight code examples in the actual programs later.

Selection

Select can be described as making a choice based on a criteria. Think of it as IF this THEN that.

It can add new options to your scenario: IF you take milk with your tea THEN add milk to your tea

Or it can create more efficient scenarios: IF the kettle has no water THEN fill the kettle with water

Rather than always filling the kettle with water, you’re asking a question first then making a decision based on the answer.

Selection is an important part of coding. It helps us choose different paths and react to situations.

Iteration

Iteration is repeating situations. There are many different types of iteration.

You can repeat a task a set number of times: Stir the tea 3 times

You can repeat a task until something happens: Stir the tea until the milk has mixed into the tea

We will highlight these different types of repetition in the upcoming projects.

Back to our cup of tea

Let’s look at our cup of tea task with Sequence, Selection and Iteration applied. We have the same number of steps but our process has become more precise (how long to stir for), efficient (we don’t fill the kettle if it has water in it already) and we have choice (milk or no milk)

  1. IF the kettle has no water THEN fill the kettle with water
  2. Turn the kettle on
  3. Put tea bag in cup
  4. Pour hot water into cup
  5. Remove tea bag
  6. IF you take milk THEN add milk
  7. Stir until the milk has mixed into the tea

Your daily life

Where else in your daily life can you see sequence, selection and iteration? These are not just programming concepts, these apply everywhere. Discuss in the comments a task you’ve noticed has one or all of these concepts. Any new ones you’ve just discovered?

This article is from the free online

Build a Physical Computing Prototype

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