Home Module 4: Python Basics Lesson 4.3
Module 4: Python Basics

Loops — making computers repeat without getting tired

⏱ 25 min build Ages 9 & 12
💡 The big idea

Loops are one of the most powerful ideas in programming. They let computers do something many times — instantly, perfectly, without complaining. Once you understand loops, you can automate almost anything.

🔄
Two types of loops
for loop
for i in range(5): print(i)

Runs a fixed number of times

while loop
x = 0 while x < 5: print(x) x = x + 1

Runs until a condition is false

🗣 Critical rule: Python uses 4 spaces of indentation (or a tab) to show which lines are INSIDE the loop. No spaces = not in the loop. Wrong spaces = Python crashes.
🔨
Build with Claude
Write a Python program using a for loop that counts from 1 to 10. After each number, print something funny. Explain how the loop works line by line for a 10-year-old who has never coded before.
Write a Python program that asks the user to guess a number between 1 and 10. Keep asking until they get it right. Use a while loop. Explain each line.
📝
Lesson quiz — test yourself!
Wrap-up discussion questions
1️⃣ What does range(5) produce? Does it start at 0 or 1?
2️⃣ What is the difference between for and while loops?
3️⃣ Why are the indentation spaces so important in Python?
📍 Lesson 4.3 — Python Basics
← Previous Next →