Using REPETITION in Scratch

REPETITION is a very useful function on coding and saves time rather than doing a long list of code.  The basic idea is that you can have a variable and then write code so the variable increases by 1 (or another number) until a certain number is reached.

Example: To get Scratch to work out the 5x table

Using pseudocode:

  1. Declare a variable called MULTIPLIER
  2. Make MULTIPLIER = 0
  3. Work out 5 x MULTIPLIER
  4. PRINT the answer
  5. Add 1 to MULTIPLIER
  6. Repeat steps 3 – 5
  7. STOP the code when MULTIPLIER = 12

This is how the code looks like in Scratch.

repetition

 

 

Be Sociable, Share!

Leave a Reply