Loops Part 1: Sense Basics 5.1
Channel: Paul Carter
Date: 2014-11-12

All programming languages include constructs for causing instructions to be executed repeatedly. 
In computing, repeated execution is often referred to as iteration.
As you learned earlier, such constructs are known as loops. In Sense, when a program encounters a loop it executes each of the blocks inside the loop – the loop’s contents – before ‘looping’ back to the top and beginning all over again. There are three general types of loop:

loops whose contents are executed a fixed number of times
loops whose contents execute forever
loops whose contents are repeatedly executed dependent on some Boolean condition.

You have already encountered the first two types of loop in the form of the Sense blocks repeat[]{} and forever{}. In this session you will first review these two types of loop, before being introduced to loops that are controlled by a Boolean condition.

In this session some of the programming exercises will not require you to construct even parts of programs; instead you may be given a program and asked to read and understand it, explain how it works and so on, sometimes experimenting by making small amendments. This approach has two main benefits:

It will develop your ability to understand programs written by other people.
It will stand you in good stead for the Sense programs that you will meet later in TU100. Some of these may be quite complex and you will not be expected to understand them entirely; instead you will be directed to small parts of them to understand and amend.
Along the way you’ll be introduced to some more Sense features that will help you to create interesting programs.

If you are not yet an Open University student and would like to know more about learning to program using Sense or would like more information about studying Information and Communication Technologies then use this link to go to the Open University website:

www.computing.open.ac.uk/