Round and Round A song about variables and loops

Subject
Computer science
Genre
Pop
Level
Ages 10–14
Length
1:37
Tempo
104 BPM

Sing it back

Can you finish the lyrics?

Eight quick questions on “Round and Round”. No music, just your memory. Then share your score and challenge a friend.

Variables and loops in one paragraph

A variable is a named place in a program that stores a value, like a labelled box, and assignment puts a new value into it. A loop repeats a block of code: a for loop repeats a set number of times, and a while loop keeps repeating as long as its condition is true, stopping when it becomes false. If the condition never becomes false, the program is stuck in an infinite loop.

Key facts from the song

  • A variable is a named box in memory that stores a value, such as score = 0.
  • Assignment (=) puts a value into a variable, replacing whatever was there before.
  • A for loop repeats a set number of times; in Python, for i in range(5) runs five times, with i going from 0 to 4.
  • A while loop repeats while its condition is true; if it never becomes false, you get an infinite loop.

Where it fits in your course

GCSE
GCSE Computer Science: Programming
England
KS2, KS3

Lyrics

Verse 1

A variable’s a named box where a value can be stored

Write score equals zero, and there’s zero in the box called score

Assign a new value later, and the old one’s swapped away

Its value can vary as the program runs, it doesn’t have to stay

Chorus

Round and round, a for loop runs a set number of times

Repeating the same code, so you don’t write a hundred lines

A while loop keeps on going while its condition’s true

When the condition turns false, the loop is finally through

Verse 2

For i in range five, the loop runs five times, zero up to four

While lives are more than zero, keep on playing one game more

If the condition never turns false, the loop goes round for good

An infinite loop! Update the variable, like you know you should

Chorus

Round and round, a for loop runs a set number of times

Repeating the same code, so you don’t write a hundred lines

A while loop keeps on going while its condition’s true

When the condition turns false, the loop is finally through

Outro

A variable’s a box, and a loop goes round and round

For loops count the times, while loops stop when false is found

Variables and loops flashcards

Say the answer out loud, then tap the card to check it. Or test yourself quick-fire.

  1. 1What is a variable?

    A named box in memory that stores a value, such as score = 0.

  2. 2What does assignment (=) do?

    It puts a value into a variable, replacing whatever was there before.

  3. 3In Python, how many times does for i in range(5) run, and what values does i take?

    Five times, with i going from 0 to 4.

  4. 4When does a while loop stop?

    When its condition becomes false.

Questions about variables and loops

Still wondering about something? Ask us and we’ll reply within two working days.

What is the difference between a for loop and a while loop?

A for loop is used when you know how many times to repeat, such as five times. A while loop repeats for as long as a condition is true, so it suits cases where you don’t know in advance how many times it will run.

What is an infinite loop?

A loop that never stops because its condition never becomes false, often because the variable it checks is never updated inside the loop.

Why is it called a variable?

Because the value it stores can vary: the program can change it while it runs.

Welcome to BrainBeats

Sign in or create your free account

No password needed. Pick Google, or we’ll email you a sign-in link.

Continue with Google

or

Part of BrainBeats Plus

Unlock this song

Start your free week

7 days free, then $5.99/month billed yearly. Cancel anytime.

or

Play a free song