0
0
PythonHow-ToBeginner · 4 min read

How to Draw a House Using Turtle in Python - Simple Guide

Use Python's turtle module to draw a house by creating shapes like squares and triangles for the walls and roof. You move the turtle cursor with commands like forward() and left() to draw each part step-by-step.
📐

Syntax

The turtle module lets you control a cursor (called turtle) that draws lines as it moves. Key commands include:

  • turtle.forward(distance): moves the turtle forward by the given distance.
  • turtle.left(angle): turns the turtle left by the given angle in degrees.
  • turtle.right(angle): turns the turtle right by the given angle.
  • turtle.penup() and turtle.pendown(): lift or place the pen to stop or start drawing.
  • turtle.done(): finishes drawing and keeps the window open.
python
import turtle

t = turtle.Turtle()
t.forward(100)  # Move forward 100 units
t.left(90)      # Turn left 90 degrees
t.forward(100)  # Move forward 100 units
turtle.done()  # Finish drawing
Output
A window opens showing an L-shaped line drawn by the turtle.
💻

Example

This code moves the turtle to draw a square for the house walls, then turns and draws a triangle for the roof.

python
import turtle

t = turtle.Turtle()

# Draw square base
for _ in range(4):
    t.forward(100)
    t.left(90)

# Draw roof

t.left(45)
t.forward(70)
t.right(90)
t.forward(70)

# Finish
turtle.done()
Output
A window opens showing a square with a triangle on top, resembling a house.
⚠️

Common Pitfalls

Beginners often forget to call turtle.done(), which keeps the drawing window open. Another common mistake is not turning the turtle correctly, causing shapes to be distorted. Also, mixing up left() and right() can confuse the drawing direction.

python
import turtle

t = turtle.Turtle()

# Wrong: missing turtle.done()
for _ in range(4):
    t.forward(100)
    t.right(90)  # Using right instead of left changes shape direction

# Correct:
# for _ in range(4):
#     t.forward(100)
#     t.left(90)

# turtle.done()
Output
The window may close immediately or the shape looks rotated differently than expected.
📊

Quick Reference

CommandDescription
turtle.forward(distance)Move turtle forward by distance
turtle.left(angle)Turn turtle left by angle degrees
turtle.right(angle)Turn turtle right by angle degrees
turtle.penup()Lift pen to stop drawing
turtle.pendown()Place pen to start drawing
turtle.done()Finish drawing and keep window open

Key Takeaways

Use turtle's forward and turn commands to draw shapes step-by-step.
Always call turtle.done() to keep the drawing window open.
Turn the turtle correctly to form the desired shapes like squares and triangles.
Lift the pen when moving without drawing to position the turtle.
Practice simple shapes first to build up to drawing a house.