Loops

#coding

Loops are an integral part of coding basics! Our Loops song teaches the importance of loops in computer science. Loops make your coding more efficent and can save you time. If you are thinking about learning about loops in coding then listen to our great loops in programming song!

Lyrics

 

What are loops?

They are instructions that repeat

What are loops?

They are instructions that repeat

What are loops?

They are instructions that repeat

What are loops?

They are instructions that repeat

 

Computers love to repeat things

And they never get bored!

Loops tell them what to repeat

And repeat some more!

And loops will also help

To save a lot of time

By repeating many things

So you don’t have to keep writing

Line after line, after line, after line, after line

 

Now let’s say you got a robot friend here

And you want to teach it to climb the stairs

You can’t just say go climb those stairs

Cuz’ it’s not gonna know what to do when it’s there

You gotta be specific, give it a try

 

Left leg up, forward, down

Right leg up, forward, down

Left leg up, forward, down

Right leg up, forward, down

Left leg up, forward, down

Right leg up, forward, down

Left leg up, forward, down

Right leg up, forward, down

Left leg up, forward, down

Right leg up, forward, down

Left leg up, forward, down

Right leg up, forward, down

I did it!

 

Well that’s all good, the robot got to the top

But hold on a minute, that’s right stop!

You said a lot of the same things again and again

Is there a better way to say everything?

Yes there is, that’s where a loop comes in

Ah thanks loop, what a great friend!

Instead of writing everything many many times

You put it in a loop and write it one time

Set up a loop, put the stuff inside

Then there’s only one thing left to decide

That’s to tell the loop how many times to repeat

Yep that’s it, the loop is pretty much complete

So let’s return to our robot climbing the stairs, OK

We got the steps in a loop And soon it’s on it’s way

But let’s add other stuff in the loop for fun today

How about we get the robot to shout hooray!

 

Alright, let’s run the loop and see what happens

 

Left leg up, forward, down

Right leg up, forward, down, hooray!

Left leg up, forward, down

Right leg up, forward, down, hooray!

Left leg up, forward, down

Right leg up, forward, down, hooray!

Left leg up, forward, down

Right leg up, forward, down, hooray!

Left leg up, forward, down

Right leg up, forward, down, hooray!

Left leg up, forward, down

Right leg up, forward, down, hooray!

 

What are loops?

They are instructions that repeat (Three more)

What are loops?

They are instructions that repeat (Two more)

What are loops?

They are instructions that repeat (One more)

What are loops?

They are instructions that repeat (No more)