S0-SA3-0489
What is a Loop (doing something again)?
Grade Level:
Pre-School – Class 2
All domains without exception
Definition
What is it?
A loop is like a cycle where you do the same thing over and over again until a certain condition is met. It's a way to repeat actions without having to write them out many times.
Simple Example
Quick Example
Imagine your mother asks you to put one ladoo on each of 10 plates for a festival. Instead of saying 'Put a ladoo on plate 1, put a ladoo on plate 2, ...' she might say 'Put a ladoo on a plate, then move to the next plate, and keep doing this until all 10 plates have a ladoo.' This 'keep doing this' part is the loop.
Worked Example
Step-by-Step
Let's say you want to count from 1 to 5.
1. Start with the number 1.
2. Is the current number less than or equal to 5? Yes.
3. Print the number (which is 1).
4. Add 1 to the number, making it 2.
5. Is the current number less than or equal to 5? Yes.
6. Print the number (which is 2).
7. Add 1 to the number, making it 3.
--- (This process repeats until the number becomes 6)
8. Is the current number (6) less than or equal to 5? No. The loop stops.
Answer: The numbers 1, 2, 3, 4, 5 are printed.
Why It Matters
Loops are fundamental to almost all computer programs, making them efficient and powerful. They are used by software developers to automate tasks, by data scientists to process large datasets, and by game developers to create repeating animations or actions for characters.
Common Mistakes
MISTAKE: Not having a clear stopping condition for the loop, leading to an 'infinite loop' where the program never stops. | CORRECTION: Always ensure there's a condition that will eventually become true (or false, depending on the loop type) to make the loop end.
MISTAKE: Forgetting to change the 'counting' variable inside the loop, so the condition to stop is never met. | CORRECTION: Make sure you update the variable that controls the loop's condition with each repetition, like adding 1 to a counter.
MISTAKE: Doing one too many or one too few repetitions (off-by-one error). | CORRECTION: Carefully check your starting and stopping conditions. For example, 'less than 10' means 0-9 (10 times), while 'less than or equal to 10' means 0-10 (11 times).
Practice Questions
Try It Yourself
QUESTION: If you have a loop that says 'clap your hands 3 times', how many times will you clap? | ANSWER: 3 times
QUESTION: A robot is programmed to 'take a step, then check if it has reached the door. If not, take another step.' If the robot is 5 steps away from the door, how many steps will it take? | ANSWER: 5 steps
QUESTION: You are making a rangoli. The instruction is: 'Draw a small circle. Then, draw 4 dots around it. Repeat this entire process 3 times.' How many small circles will you draw in total? How many dots? | ANSWER: 3 small circles, 12 dots (4 dots * 3 repetitions)
MCQ
Quick Quiz
Which of these everyday actions is an example of a loop?
Reading a book from start to finish
Brushing your teeth every morning
Deciding what to eat for dinner tonight
Running a race once
The Correct Answer Is:
B
Brushing your teeth every morning is a repetitive action done under a certain condition (it's morning). The other options are usually one-time events or a single sequence of actions.
Real World Connection
In the Real World
When you scroll through your social media feed (like Instagram or Facebook), the app uses a loop to keep loading new posts as you scroll down. Or, when a traffic light changes from red to yellow to green and then repeats, that's a loop. Even the music player on your phone uses loops to repeat your favourite song or playlist.
Key Vocabulary
Key Terms
REPETITION: Doing something again | ITERATION: One single run of a loop | CONDITION: A rule that decides if the loop should continue or stop | INFINITE LOOP: A loop that never stops because its condition is never met
What's Next
What to Learn Next
Now that you understand loops, you can explore different types of loops like 'for loops' and 'while loops' in programming. You'll see how these basic ideas help build complex programs and make computers do amazing things.


