Repetition What is repetition? Repetition is the process of repeating a task a set number of times or until a condition is met. Repetition is the recurrence of actions or events. We wake up and go to sleep each day for example. We eat our lunch each lunchtime and might watch a favorite soap every evening. We might drive the same route to work, as the days in the week and months in a year repeat Repetition happens in the world around us all the time.Pixabay CC0 Public Domain Similarly, when designing algorithms to complete a task we often wish to repeat steps. Such repetition is also referred to as loops. If designing instructions for making a table we might wish to REPEAT 4 [attach table leg with screw provided]. Or, if writing the algorithm for making a cake mixture we might repeat the step whereby we ‘add a little of the flour and fold into the mixture’: REPEAT [fold flour into mix] UNTIL all flour added. In these two examples the nature of the repetition is different. When we are adding the flour to the cake mixture there is a condition which we use to stop the repetition, that is until all the flour has been added. In the case of the table construction we wish to repeat the step a fixed number of times, in this instance repeat four times. Repetition page 1/7 In Computer Science, repetition is the process of repeating a task a set number of times or until a condition is met. Drawing a square in scratch using a repeat, this is a count controlled repeat. Different types of loop There are different sorts of repetition or types of loop used in computer science both for algorithm design and when coding these include: a forever loop (infinite), count controlled loop and a conditional loop. • Forever loop: This is used to repeat actions over and over continuously for the duration that an algorithm is being followed or a program is running. For example, in an algorithm which describes how to play tig you might include the instruction forever run away from the person ‘on it’. • Count-controlled loop: We may wish to repeat steps a fixed number of times such as the table leg example above. Another example might be when drawing regular polygons, e.g to draw a triangle we REPEAT 3 times the instructions forward turn right 120 degrees. • Conditional loop: As for the case of folding flour into a cake mixture above, we may wish the repetition to be terminated when a condition occurs. This can be achieved using either ‘while’ or ‘until’ loops. While repetition loops whilst a condition is true, for example: WHILE you have the ball in football move towards the opposition’s goal. Until uses a condition being true to terminate the loop: keep filling the glass with water UNTIL it is a third from the top. Repetition page 2/7 Loop commands within programming languages The images below illustrate the loop commands available in different programming languages. Image 1 shows count-controlled loop commands in Daisy the Dinosaur (top) and Logo (bottom). Image 2 shows a forever loop in Scratch used to repeat commands infinitely whilst the program is running. Here being used to control a sprite. Image 3 shows a conditional loop in Scratch used to terminate a loop based on a condition occurring. Here the loop stops when lives equals 0. Why is repetition important? Loops are a fundamental structure used in programming. Many programs employ repetition: in a quiz we may wish to ask the player a set number of questions or keep asking questions until they run out of lives, for example. In a game we may wish for objects to continuously hide and reappear or to keep pointing, and moving towards, a main character as they chase them. Programs which control physical systems often employ repetition also. Traffic lights at a pedestrian crossing keep displaying the green light until the button is pushed for example, and an air conditioning unit will keep blowing out cold air until a desired room temperature is met. The use of repetition enables us to write shorter more efficient algorithms or programs. Having decomposed our task to create an algorithm, we look for patterns to find common steps that are repeated, this reduces the number of steps in our design. When we use this to help us write our program the repeated steps can be implemented as a loop using the relevant commands in the programming language. Repetition page 3/7 Employing loops also enables us to create programs which can be easier to alter if required, as the repeated code needs to be altered only once. For example, the screenshots below show two programs used to draw a triangle in Scratch, one of which employs a count-controlled loop. By using this loop command we need only alter one value (circled), as opposed to 3, in order to alter the size of the square which the programs draws. Indeed this program can quickly be modified to drawn an entirely different regular polygon by simply changing the number of times the program is set to repeat and the angle through which the sprite should rotate. Two programs for drawing a triangle in Scratch. The program using repetition can quickly be altered to draw a triangle with sides of a different length, by just changing the value circled just once. What does repetition look like the primary curriculum? EYFS Pupils can be introduced to the repetition in the world around them. They notice things that always repeat such as the cycle of day and night. Things that repeat sometimes such as coming to school Monday through Friday. The school day itself has a repeating pattern as pupil have their play times, lunch and snack at the same time each day. Pupils learn routines in school, such as how to hang up their coat, line up nicely, follow the golden rules, they repeat these routines on a daily basis. As teachers we can draw attention to these regular tasks and start to use simple vocabulary associated with repetition. Children initiate repetition of activities and are encouraged to think about activities they might repeat and how they might keep things the same or change what they do. Many nursery rhymes and education songs have repeating phrases or verses and as pupils learn to count beyond 10 they may recognise the repetition in digits. Repetition page 4/7 KS1 Pupils continue to recognise repetition in the world around them and across the curriculum. For example, pupils may notice the continued repetition of numerals in the decimal number system as they count to larger numbers helping them learn about place value. They may see that numberals repeat on a number square helping them to spot patterns and create rules on how to work out 10 more or 10 less than a number. They learn that multiplication is repeated addition. They are asked to spot repetition of events in stories or the repetition across story structures, such as there always being a problem. In music they learn to repeat simple phrases, in PE they repeat actions, in science they repeat experiments on different materials. When designing algorithms pupils may instinctively incorporate repetition based commands without explicitly stating this for example when writing the algorithm for making a jam sandwich they might say ‘Spread the butter on the bread’ meaning to keep spreading the butter until the butter covers the slice. As teachers we can start to model a more precise use of language to introduce the concept of repetition. Pupils experience of repetition within computing lessons is likely to be limited, since the focus at key stage 1 is on developing an understanding of sequence. Simple programmable devices such as the Bee Bot do not offer repetition functions. However digital devices such as the Roamer, Pro-Bot and BigTrack have count controlled repeats that pupils can explore. Pupils may also have the opportunity to use simple graphical programming languages such as Daisy the Dinosaur and Scratch Junior which also include count-controlled loop commands, as shown below. Daisy the Dinosaur (left image) has a count-controlled loop fixed at 5 repetitions. ScratchJr (right image) includes a count-controlled loop command which visually loops around the commands to be repeated. The number of repetitions can be varied. KS2 Use repetition in programs Throughout key stage 2, pupils should have the opportunity to design, write and debug programs that use repetition to accomplish specific goals. Ideally this should be across different programming languages. In doing so they will have to design the algorithms for these programs indicating how and where repetition will be used. Pupils may first have the opportunity to tinker with repetition commands to develop their understanding of how these work and the similarities and differences between different loop types. When designing their algorithms or writing their code, pupils should have experience of looking for steps or commands that are repeated and Repetition page 5/7 identifying the opportunities to use a loop and work out what form of loop is most suitable. When using conditional or count-controlled loops, pupils have to identify the appropriate conditions for loop termination, or the number of times the loop should repeat. When evaluating code pupils might compare programs with or without. When evaluating their projects pupils might be asked to identify how their programs can be made more efficient through the use of repetition. Some examples of how repetition may be used within pupils’ programs at key stage 2 are shown below. Image 1 shows the use of count-controlled loop within Logo to draw a triangle. Image 2 shows the use of forever and conditional loops for creating a simple stopwatch in Scratch. Image 3 shows the use of count controlled repetition in Scratch to create pattern artworks from tracing out lines. A conditional loop nested within a second conditional loop in a program that reproduces the counting rhyme ‘One man went to mow’. Repetition page 6/7 Find out more about repetition Wikipedia article on loops in programming Resources by Phil Bagge explaining count-controlled loop Resources by Phil Bagge explaining forever loops Scratch wiki explaining: forever loop; count-controlled loop; conditional loop Related concepts: algorithms, programming, sequence, selection A note about repetition in Kodu A popular graphical programming language is Kodu. When using Kodu you will notice the lack of repetition commands. This is due to the nature of the Kodu programming environment. In Kodu when the program is run, all the commands are triggered to run all the time as though each command is running as a forever loop waiting for its condition to occur. For example the bump command below is waiting for the ‘sprite’ to be bumped by another ‘sprite’, as soon as this occurs then 10 points are deducted from the score. Consequently there is no need to specifically add repeat commands. An example of commands being used to create a program in Kodu. These may be considered as running within a forever loop. Repetition page 7/7
© Copyright 2026 Paperzz