Minu's Games logo
MINU'S ROBOTICS

A Minu's Games EdTech Lab

← Code & Cognition
Day 8 of 30Logic & Data Structures

🔁Loops with for & range

🎯 Today's objective

Repeat actions automatically.

📖 Key concepts

  • for repeats over a sequence
  • range(n) → 0..n-1
  • range(a, b, step)
  • Loop body is indented

💻 Try this code

for i in range(1, 6):
    print(i, "x 7 =", i * 7)

for letter in "AI":
    print(letter)

👥 Learn it your way

🧒 Young Explorers

Loops save you from copy-paste — tell the robot "do this 100 times".

Your task

Print the 9× table, and print a triangle of stars (*, **, ***...).

💼 Professionals

Prefer iterating directly over collections; use enumerate() for indices.

Your task

Sum the numbers 1..100 with a loop, then print the running total every 10 steps.

🤖 AI connection

Training a model means looping over data many times ("epochs"), nudging it to improve each pass. Loops are the heartbeat of learning.

✅ Quick check

What does range(3) produce?

0, 1, 2

How do you loop with both index and value?

enumerate(sequence)