Adding a Roof
Draw a triangle.
Adding a Roof is a free Coding for Kids lesson on CoddyKit — lesson 2 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.
Time for a Roof! 🔺🏠
Our house has walls but no roof! 🌧️ It would get wet inside!
A roof is a triangle on top. Let's learn to draw one! 🔺
import turtle
t = turtle.Turtle()
t.forward(100)A Triangle Has 3 Sides 🔺
A triangle has 3 equal sides. At each corner the turtle turns 120 degrees.
Why 120? Because 360 ÷ 3 = 120! The turtle goes all the way around. 🔄
import turtle
t = turtle.Turtle()
t.forward(100)
t.left(120)
t.forward(100)
t.left(120)
t.forward(100)A Triangle With a Loop 🔁
Just like the square, we can use a loop! 🔁
for i in range(3): repeats forward and turn 3 times. A perfect triangle! 🔺
import turtle
t = turtle.Turtle()
for i in range(3):
t.forward(100)
t.left(120)First the Walls 🏠
Let's draw the house walls again. This is our square from last lesson! 🟦
We'll add the roof on top in the next steps.
import turtle
t = turtle.Turtle()
for i in range(4):
t.forward(120)
t.left(90)Get to the Top of the Walls 🧗
After drawing the walls, the turtle needs to be at the top-left corner to start the roof.
We lift the pen, move up, and put it down. penup() and pendown() to the rescue! ✈️
import turtle
t = turtle.Turtle()
for i in range(4):
t.forward(120)
t.left(90)
t.left(90)
t.forward(120)Draw the Roof Triangle 🔺
Now the turtle is at the top! Let's draw a triangle roof.
We point the turtle and draw 3 sides. The roof sits right on the walls! 🏠
import turtle
t = turtle.Turtle()
for i in range(4):
t.forward(120)
t.left(90)
t.left(90)
t.forward(120)
t.right(60)
for i in range(3):
t.forward(120)
t.right(120)Color the Roof Red ❤️
Roofs are often red! Let's fill the triangle with red. 🟥
Use fillcolor('red'), then begin_fill() and end_fill() around the triangle.
import turtle
t = turtle.Turtle()
t.fillcolor('red')
t.begin_fill()
for i in range(3):
t.forward(120)
t.right(120)
t.end_fill()A House With a Red Roof 🏠❤️
Let's put it together: yellow walls and a red roof! 🎨
Draw the filled square, move to the top, then draw the filled triangle.
import turtle
t = turtle.Turtle()
t.fillcolor('yellow')
t.begin_fill()
for i in range(4):
t.forward(120)
t.left(90)
t.end_fill()
t.left(90)
t.forward(120)
t.right(60)
t.fillcolor('red')
t.begin_fill()
for i in range(3):
t.forward(120)
t.right(120)
t.end_fill()Make the Roof Pointy ⛰️
Want a taller, pointier roof? Change the turn angles! 📐
A pointier roof looks like a castle tower! Try different numbers to see. 🏰
import turtle
t = turtle.Turtle()
t.fillcolor('darkred')
t.begin_fill()
t.forward(120)
t.left(120)
t.forward(120)
t.left(120)
t.forward(120)
t.end_fill()Thick Roof Lines ✒️
Make the roof stand out with thicker lines using t.pensize(3)! 💪
A bold outline makes the house look strong. 🏠
import turtle
t = turtle.Turtle()
t.pensize(3)
t.fillcolor('crimson')
t.begin_fill()
for i in range(3):
t.forward(120)
t.right(120)
t.end_fill()Make Your Own Roof! 🔺🎨
Your turn! Pick a roof color and draw the triangle. 🤩
Change 'green' to your favorite color. Maybe a magic rainbow roof? 🌈
import turtle
t = turtle.Turtle()
t.fillcolor('green')
t.begin_fill()
for i in range(3):
t.forward(120)
t.right(120)
t.end_fill()Quick Check ✅
Roof brain teaser time! 🧠🔺
Roof Done! 🏠❤️🎉
Awesome! Your house has a roof now! You learned:
- A triangle has 3 sides and turns of
120🔺 for i in range(3):draws it with a loop 🔁- Fill the roof red with
begin_fill()andend_fill()❤️
Next: doors and windows! 🚪🪟
Frequently asked questions
Is the “Adding a Roof” lesson free?
Yes — the full text of “Adding a Roof” 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 “Adding a Roof”?
Draw a triangle. 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 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Adding a Roof” 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
- Drawing a Square House
- Adding a Roof
- Doors and Windows
- A Sun and Sky