Electronics · lesson 25 of 30 · free

Loops and variables — Electronics for kids

A variable is a named box that stores a value, like count or total. A loop repeats some lines: “repeat 5 times { count = count + 3 }” adds 3 five times, so count goes 0 → 3 → 6 → 9 → 12 → 15. A loop inside a loop multiplies (3 × 4 beeps), and a while loop keeps going until its condition becomes false. Tracing values step by step is how programmers find mistakes.

▶ Watch how it works

Got it? Practise ↓

Remember

Trace every pass — “write the value of each variable after each time round the loop”

  1. count = count + k adds k each time round; after n rounds: start + n × k.
  2. A loop inside a loop runs outer × inner times.
  3. while (condition) repeats until the condition is false — count the rounds as you trace.

Use it for: Reading and debugging microcontroller programs, counting button presses and coding lessons on loops.

Worked example: 🔁 count = 0 repeat 5 times { count = count + 3 } What is count at the end? → 15

  1. count goes 0 → 3 → 6 → 9 → 12 → 15.
  2. 0 + 5 × 3 = 15.

Check: 15 ÷ 3 = 5 rounds ✓

▶ Watch it animated

✏️ Practice

Work it out in your head or on paper, type the answer and press Check. Stuck? Press “Show me how”.

Right: 0 · Tried: 0

🏁 Lesson 25 test

20 questions. Check each answer, then go to the next one. Get 16 or more right to pass.

🏅 Sign in with Google to earn the 🔁 Loop Tracer badge when you pass — and a certificate when you finish all 10 lessons of Part 3 · Microcontrollers and IoT. You can still take the test without signing in.

🖨️ Electronics Worksheet: Loops and Variables

✨ Free AI tutor

Ask the AI tutor about this lesson

Why does it work? When should you use it? Ask in English, मराठी or हिंदी.

Sign in with Google to ask Free — 20 questions a day.

👩‍🏫 Electronics classes near you — online or at home

Prefer a real teacher? TalentJR teachers take live online classes anywhere in India and visit homes in selected cities. Tell us what you need and our team will call you with timings and fees.

Live online classesSmall groups or 1:1 with a teacher, from home, any city.
Teacher at homeA TalentJR teacher visits your home (selected cities).
At a centreClasses at a TalentJR partner centre near you, where available.
Badges, certificates & gifts A badge for every lesson you pass, a certificate for every part you finish, plus TalentJR Points for daily practice. Computer worksheets Flowcharts, block coding and spreadsheets.