Shot of a man speaking to an off-screen interviewer.
On-screen text reads 'Mark, created Facebook'.
MARK: One thing that computers are really good at is repeating commands. As a person, you'd get really bored if you had to do the same thing lots of times in a row, but a computer can do the same thing millions or even billions of times and not get bored and be able to carry that out really well. So, for example, if I wanted to wish everyone on Facebook a Happy Birthday by sending them an email, it might take me more than a century to actually write out all of those emails to everyone.
On-screen text reads 'Happy birthday'.
On-screen graphic shows 'Happy birthday' text multiplying to fill the screen before disappearing.
MARK: But with just a few lines of code, I can have a system send an email to everyone on Facebook, wishing them a Happy Birthday.
(Happy Birthday melody)
MARK: So that's what loops are and why they are valuable and something that computers can do very well. In this example, your goal is going to be to move the Bird to hit the Pig.
On-screen graphic of a red Angry Bird rolling into a green Pig.
(Bird squawks)
MARK: Now, we're gonna be able to use the 'repeat' block in order to be able to do this very easily.
On-screen graphic shows a programming block in Blockly labelled 'repeat'.
MARK: You can either do this by giving the computer a 'move forward' command five times in order to advance the Bird one step each time to the Pig.
On-screen graphic shows five blocks labelled 'move forward' clicked together.
MARK: Or you can just tell the computer to move forward once and then tell it to repeat that five times and it'll do the same thing.
On-screen graphic shows one 'move forward' block with the on-screen text 'x 5'.
MARK: So, in order to do this, you drag your 'move forward' command and then you put it inside the 'repeat' block.
On-screen graphic shows the mouse cursor drag a 'move forward' block to click into a 'repeat' block.
MARK: And you can click on it and tell it how many times you want to repeat the block to tell it how many steps you want it to move forward.
On-screen graphic shows a text cursor type '5' into a text box on the 'repeat' block.
MARK: Now, one more thing is you can put as many commands as you want inside the 'repeat' block. So in this example, you're telling it to move forward and turn left, which it will do five times.
On-screen graphic shows the mouse cursor drag a 'turn left' block to click beneath the 'move forward' block in the 'repeat' block.
MARK: Alright. Good job and have fun!