Repeating Things: How Loops Work Think about brushing your teeth. You do not brush once and stop. You brush, and brush, and brush again — the same movement, over and over — until two minutes are done or your arm gets tired. That repeating action has a name in programming. It is called a loop . What is a Loop? A loop is simple: do something again and again . But every loop also needs an answer to one question: when do you stop? There are two easy ways a loop knows when to stop: Way 1: Do it a certain number of times "Clap your hands 10 times ." You know exactly when to stop — after clap number 10. You count as you go. Way 2: Keep going UNTIL something happens "Keep walking UNTIL you reach the door." You do not know how many steps it will take. You just keep going and check — am I at the door yet? The moment the answer is yes, you stop. Both of these are loops. They just have different stopping rules. Loops You See Every Day Brushing Teeth > Move the brush up and down → move the brush up and down → move the brush up and down… STOP when: 2 minutes are done (your timer beeps) This is a "keep going UNTIL" loop. You do not count your strokes — you just go until the timer tells you to stop. Eating Crisps from a Packet > Take a crisp → eat it → take another crisp → eat it → take another… STOP when: the packet is empty No counting needed. You just keep going and stop when there is nothing left. The School Bell A school rings the bell at the start of each period. How many times does it ring in a day? > Ring the bell → wait 45 minutes → ring the bell → wait 45 minutes → ring the bell… STOP when: 8 periods are done (the school day ends) This is a counting loop — it rings exactly 8 times, then stops. The Blinking Festival Lights Those decorative lights that blink around Diwali or Christmas? They follow a simple pattern: on, off, on, off, on, off… > Turn ON → wait → turn OFF → wait → turn ON → wait… STOP when: someone switches off the plug Until someone stops it, they just keep blinking forever. Some loops do not stop on their own — they run until you switch them off. The Magic of Loops Here is why loops matter. Imagine you want to say "Happy Birthday!" to every student in your school — 600 people. Without a loop: say it once, say it twice, say it a third time… 600 separate instructions. With a loop: say "Happy Birthday!" — and repeat that 600 times . Same result. But the loop version takes one instruction instead of 600. Computers use this to do enormous amounts of work incredibly fast. A computer can repeat something a million times in less than a second — without getting bored, without forgetting, without making a mistake after repetition. Two Questions for Every Loop Before a computer runs any loop, it needs answers to two things: 1. What should it repeat? (The action) 2. When should it stop? (The stopping rule — either a count or a condition) Without the stopping rule, the loop runs forever. That is called an infinite loop — and it is the kind of mistake that freezes programmes. Always know how your loop stops. The Three Ideas So Far Idea What it means Simple example ------ --------------- ---------------- Sequence Follow steps in order Traffic signal: Red → Yellow → Green (always in that order) Decision Do different things based on a condition News ticker: if breaking news → red banner Loop Repeat steps, stop when the rule says so School bell rings 8 times, one per period In the final post, we put all three together and see how every programme ever written — no matter the size — uses exactly these ideas. ✅ Summary A loop repeats an action. Every loop needs a stopping rule — either "do this X times" (counting) or "keep going UNTIL this happens" (condition). Brushing teeth, eating crisps, the school bell, and blinking lights are all loops. Loops let computers do huge amounts of work quickly, without getting tired or making mistakes. Together with sequences and decisions, loops are one of the three ideas behind every programme.