Untitled

mail@pastecode.io avatar
unknown
plain_text
17 days ago
800 B
0
Indexable
Never
import turtle

# Set up the screen
screen = turtle.Screen()
screen.bgcolor("skyblue")

# Create a turtle named house
house = turtle.Turtle()
house.speed(1)

# Function to draw a square (used for the house base)
def draw_square(size):
    for _ in range(4):
        house.forward(size)
        house.left(90)

# Function to draw a triangle (used for the roof)
def draw_triangle(size):
    for _ in range(3):
        house.forward(size)
        house.left(120)

# Draw the base of the house
house.penup()
house.goto(-50, -50)
house.pendown()
house.color("blue")
draw_square(100)

# Draw the roof
house.penup()
house.goto(-50, 50)
house.pendown()
house.color("red")
draw_triangle(100)

# Hide the turtle and finish
house.hideturtle()

# Keep the window open until it is closed by the user
turtle.done()
Leave a Comment