0Pricing
Coding for Kids · Lesson

Star Triangles

Grow patterns.

Star Triangles is a free Coding for Kids lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Coding for Kids learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Triangles of Stars! ⭐

Hi artist! 🎨 Today we draw triangles made of stars that grow bigger row by row! ⭐

Like this:

  • *
  • **
  • ***

Let's learn the magic!

print('*')
print('**')
print('***')

Growing Rows 📈

See how each row has MORE stars? Row 1 has 1, row 2 has 2, row 3 has 3. 📈

The trick: the inner loop runs a DIFFERENT number of times for each row!

for row in range(3):
    print('Row', row, 'needs', row + 1, 'stars')

Using row in the Inner Loop 🔑

Here's the secret key 🔑: the inner loop's range depends on the outer loop's number!

We use range(row + 1) so row 0 gets 1 star, row 1 gets 2 stars, and so on.

for row in range(3):
    for star in range(row + 1):
        print('*', end='')
    print()

A Bigger Triangle 🔺

Want a taller triangle? Just make the outer range bigger! Try 5 rows. 🔺

for row in range(5):
    for star in range(row + 1):
        print('*', end='')
    print()

Triangle With Emojis 🌟

Stars are great, but emojis are FUN! Let's build a triangle of glowing stars! 🌟

for row in range(4):
    for s in range(row + 1):
        print('🌟', end='')
    print()

Shrinking Triangle 🔻

What if we want a triangle that gets SMALLER? We can flip the counting! 🔻

Row 0 gets the most, and each row gets fewer. Cool upside-down look!

for row in range(4):
    for s in range(4 - row):
        print('*', end='')
    print()

Counting the Stars 🔢

How many stars are in a triangle with 3 rows? Let's count: 1 + 2 + 3 = 6! The computer can add them up for us. 🔢

total = 0
for row in range(3):
    for s in range(row + 1):
        total = total + 1
print('Total stars:', total)

Numbers Instead of Stars 1️⃣

Instead of stars, let's print the row number! It makes a neat number triangle. 1️⃣2️⃣3️⃣

for row in range(5):
    for s in range(row + 1):
        print(row + 1, end='')
    print()

Add Spaces for Style 🌬️

A little space between stars makes the triangle look airy and pretty! 🌬️

for row in range(5):
    for s in range(row + 1):
        print('*', end=' ')
    print()

Heart Triangle 💖

Let's spread some love! A growing triangle of hearts. 💖 Try changing the height too!

for row in range(5):
    for s in range(row + 1):
        print('💖', end='')
    print()

You're a Pattern Pro! 🚀

Now YOU control the magic! Change the number 6 below to make it taller. Try your own emoji too! 🚀

The big idea: range(row + 1) grows the rows!

for row in range(6):
    for s in range(row + 1):
        print('🍕', end='')
    print()

Quick Check! 🧠

Time to test your triangle smarts! 🔺

Triangle Champion! 🎉

You did it! 🎉 You can grow patterns!

  • Use the outer number inside the inner loop ✨
  • range(row + 1) makes rows GROW 📈
  • range(4 - row) makes rows SHRINK 📉
  • Add spaces or emojis for style 🌟

Next: the times table! ✖️

for row in range(5):
    for s in range(row + 1):
        print('⭐', end='')
    print()

Frequently asked questions

Is the “Star Triangles” lesson free?

Yes — the full text of “Star Triangles” is free to read here on the web, and the Coding for Kids course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Coding for Kids course, upgrade to CoddyKit PRO.

What will I learn in “Star Triangles”?

Grow patterns. You practise Coding for Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Coding for Kids?

No prior experience is required. Coding for Kids on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Star Triangles” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Coding for Kids lesson?

Yes. Every Coding for Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. A Loop Inside a Loop
  2. Drawing a Grid
  3. Star Triangles
  4. Multiplication Table
← Back to Coding for Kids