Learn Without Walls
← Back to Python Practice Labs
Lab 3 of 10

Loops & Iteration

Making Python do the repetitive work for you

← Lab 2: Conditionals Lab 3 of 10 Lab 4: Functions →
⏳ Loading Python... (first load takes ~10 seconds)

📖 Concept Recap

👀 Worked Example

Three different loop patterns with the same list:

fruits = ["apple", "banana", "cherry", "date"] # Basic for loop for fruit in fruits: print(fruit) print("---") # enumerate — get index AND value for i, fruit in enumerate(fruits): print(f"{i+1}. {fruit}") print("---") # zip — pair two lists together prices = [1.20, 0.50, 2.00, 3.50] for fruit, price in zip(fruits, prices): print(f"{fruit}: ${price}")
✏️ Guided

Exercise 1 — Multiplication Table Generator

Complete the multiplication table generator by filling in the blanks. The table should print lines like 7 × 1 = 7 through 7 × 12 = 84.

Output will appear here...
💡 Hint: range(1, 13) gives 1 through 12. The result is number * i.
💪 Independent

Exercise 2 — Divisibility Finder

Write a loop that finds all numbers between 1 and 100 that are divisible by both 3 and 7. Print each one, and at the end print how many there are total.

Output will appear here...
💡 Hint: A number divisible by both 3 and 7 must be divisible by 21. Use if n % 21 == 0 or if n % 3 == 0 and n % 7 == 0. Keep a counter variable.
🔥 Challenge

Exercise 3 — Number Guessing Game Simulation

Write a number guessing game simulation (no user input — use a preset list of guesses). Rules:

Output will appear here...
💡 Hint: Use enumerate(guesses, 1) to track the attempt number. Use break when you find the secret. Use a for...else clause to handle the not-found case.
🏆 Mini Project

Mini Project — Weekly Sales Summary

Analyze 8 weeks of sales data. Your loop should calculate and print:

Output will appear here...
💡 Hint: Calculate total and average first. Then loop through with enumerate(weekly_sales, 1) to track week numbers. Use max()/min() or track them manually in the loop.

✅ Lab 3 Complete!

You’ve practiced for loops, enumerate, zip, break, continue, and real data analysis with loops. Loops are the engine of data processing.

Continue to Lab 4: Functions →

← Lab 2: Conditionals Lab 3 of 10 Lab 4: Functions →