We write a computer program because we want a computer or computing device to complete a task. This task might be part of a larger project, or it might be a way to solve a problem.
When we write a story, we know it must have certain structures to make it work for the reader.
The story will have events, or things that happen in a particular order, or sequence. We call this the plot, and the sequence is usually the beginning, followed by the middle and finally the end.
The story will also usually include descriptions of the characters and the story setting.
In a drinks factory, the machines are all controlled by computers. The machines:
- Move the empty bottles automatically around the different sections
- Fill up the bottle
-
THEN put the lids on
Can you describe what would happen if they got the computer program sequence wrong and put the lids on first?
Repeating something, or doing the same thing more than once, can be a good way to learn or remember something new.
Imagine you were going to show an alien how to help tidy up your room. You would have to give them careful instructions.
You could say:
- Walk up to a toy on the floor
- Pick up the toy
Put the toy in the toy cupboard
But there are 20 things to tidy up – you must have been very untidy lately.
You could just repeat the same 20 times, but it would take a long time to tell the alien the same instructions over and over again.
Nearly as long as it would take to tidy your room!
If the alien was a robot you could use a instruction like this:
Repeat 20 times:
- Walk up to a toy on the floor
- Pick up the toy
- Put the toy in the toy cupboard
The repeat command turns the instruction list into a repeat loop, where we go round and round the loop 20 times.