Robotics · lesson 22 of 30 · free

Loops and shapes — Robotics for kids

A loop repeats the same commands. repeat 4 { forward 10 cm; turn right 90° } drives four equal sides with four right-angle turns — a square, and the robot drives 4 × 10 = 40 cm in all. For any regular shape with n sides, each turn is 360 ÷ n degrees: 120° for a triangle, 72° for a pentagon, 60° for a hexagon and 45° for an octagon. A loop inside a loop multiplies: repeat 3 { repeat 4 {…} } runs the inside 12 times.

▶ Watch how it works

Got it? Practise ↓

Robot tip

Repeat the side — “a loop repeats forward + turn; the turns of a closed shape add up to 360°”

  1. repeat n { forward s; turn right A° } drives n sides: distance = n × s.
  2. A closed regular shape needs n × A = 360°, so A = 360 ÷ n.
  3. Rectangle: repeat 2 { forward a; turn 90°; forward b; turn 90° } → perimeter 2 × (a + b), area a × b.

Use it for: Drawing shapes with a robot or a turtle program, perimeter and angles in maths, and loops in coding.

Worked example: 🔁 A drawing robot runs: repeat 4 { forward 10 cm; turn right 90° } How many cm does it drive in all? → 40

  1. The loop drives 4 sides of 10 cm (a square).
  2. 4 × 10 = 40 cm.

Check: 4 turns of 90° = 360°, so the square closes ✓

▶ 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 22 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 🔁 Shape Looper badge when you pass — and a certificate when you finish all 10 lessons of Part 3 · Programming robots. You can still take the test without signing in.

🖨️ Robotics Worksheet: Loops and Shapes

✨ 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.

👩‍🏫 Robotics 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. Electronics & IoT Circuits, sensors and microcontroller boards.