👩‍🏫

Nested Loops & Conditionals

Super Coding Power! 🚀
With your kind teacher Mrs. Brenda ❤️

Hi my amazing Grade 6 coders! 👋

Today we’re learning two superpowers that make our programs really smart: Nested Loops and Conditional Statements! Together they help us solve tricky problems like drawing patterns, playing games, and making decisions.

🔄 ➕ ❓

1. Quick Review: What is a Loop?

A loop repeats the same action many times.

Example: “Print ‘Hello’ 5 times”

for i from 1 to 5:
    print("Hello")

2. Nested Loops (Loops Inside Loops!)

A nested loop is when we put one loop inside another loop. It’s like a clock: the minute hand goes around many times while the hour hand moves slowly.

for row from 1 to 3:
    for column from 1 to 5:
        print("*")
    print("---")

This makes a pattern of stars:
*****
*****
*****

3. Conditional Statements (Making Decisions)

Conditionals use if and else to make choices.

score = 85
if score > 80:
    print("Great job! ⭐")
else:
    print("Keep trying!")

4. Nested Loops + Conditionals = Magic!

Let’s make a fun pattern where even numbers become hearts ❤️ and odd numbers become stars ⭐

for row in 1 to 4:
    for col in 1 to 6:
        if (row + col) % 2 == 0:
            print("❤️")
        else:
            print("⭐")
    print("")

5. Let’s Practice Together! 🎮

Practice 1: How many stars will this print?

for i in 1 to 3:
    for j in 1 to 4:
        print("*")
12 stars! (3 rows × 4 columns = 12) ⭐

Practice 2: What will this code print?

number = 7
if number % 2 == 0:
    print("Even")
else:
    print("Odd")
Odd because 7 divided by 2 has remainder 1 ❤️

Challenge: Create a checkerboard pattern using nested loop + if

6. Real Life Examples 🇨🇦

You are becoming an awesome coder! 🌟

Keep practicing loops and if-statements.
You can create amazing things!

Big hugs and high-fives,
Mrs. Brenda ❤️

🔄💡🚀