๐Ÿ” Python Loops Adventure - Day 4

Make your code repeat like magic! Learn loops! ๐ŸŽช

Step 1 of 6

1 Why Loops? ๐Ÿค”

๐Ÿ’กProblem: Printing "Hello" 10 times without loops = 10 lines of code!
โœจMagic! The loop repeats the indented code automatically! Change 3 to 10 and watch!

2 Your First For Loop ๐Ÿ”„

๐Ÿ“šLearn: A for loop repeats code for each number in a range!
Start
โ†’
Do action
โ†’
Repeat
โ†’
Done!
๐Ÿ”ขNotice: number changed from 0 to 4! Python starts counting at 0.

3 Understanding Range ๐Ÿ“

๐ŸŽฏLearn: range() creates sequences of numbers!
Range Examples:

range(5) โ†’ 0, 1, 2, 3, 4
range(1, 6) โ†’ 1, 2, 3, 4, 5
range(0, 10, 2) โ†’ 0, 2, 4, 6, 8
range(10, 0, -1) โ†’ 10, 9, 8, ..., 1
๐ŸงชTry: range(10, 0, -1) to count backwards from 10 to 1!

4 Multiplication Table! โœ–๏ธ

๐ŸงฎBuild: Create any multiplication table with loops!
๐ŸŒŸTry: Enter 7 for the 7 times table! Test with 3, 9, or 12!

5 Pattern Maker! ๐ŸŽจ

๐Ÿ”บChallenge: Create cool patterns with loops!
๐Ÿ’กTry: Make patterns with emojis! Use "๐ŸŒŸ" * i or "โค๏ธ" * i

6 Number Guesser Game! ๐ŸŽฎ

๐ŸŽฏFinal Project: Build a guessing game with 3 attempts!
๐Ÿš€Upgrades:
  • Change secret to a random number
  • Give 5 attempts instead of 3
  • Make range 1-100 for hard mode
  • Add a score counter