Explore

Close
Turtle Programs Share

Draw Christmas Tree In Python Turtle With Code

Draw Christmas Tree In Python Turtle

Want to draw christmas tree in python, then you are at the right place today. I will show you how to draw a christmas tree in python turtle with code, so sit down and read till the end.

You can use this program to wish merry christmas in python. This program will draw a christmas tree and it will have merry christmas written at the bottom.

To draw a christmas tree in python we will use turtle which is a python library for GUI. You can draw stuff with this library.

I will provide you the code for drawing christmas tree in python just follow me till the end of this tutorial now let’s get into code 

Draw Christmas Tree In Python Code


from turtle import *

speed(0)

# Blue Background
penup()
goto(0, -250)
pendown()
color("lightskyblue")
begin_fill()
circle(250)
end_fill()

# Tree Trunk
penup()
goto(-15, -50)
pendown()
color("brown")
begin_fill()
for i in range(2):
    forward(30)
    right(90)
    forward(40)
    right(90)
end_fill()

# Set the start position and the inital tree width
y = -50
width = 240
height = 25

# Green section of tree (add in the greater than symbol next to the 20 - YouTube doesn't allow me to put in pointy brackets).
while width > 20:
    width = width - 30 # Make the tree get smaller as it goes up in height
    x = 0 - width / 2 # Set the starting x-value of each level of the tree
    color("green")
    penup()
    goto(x, y)
    pendown()
    begin_fill()
    for i in range(2):
        forward(width)
        left(90)
        forward(height)
        left(90)
    end_fill()
    
    y = y + height # Keep drawing the levels of the tree higher than the previous

# Star
penup()
goto(-15, 150)
pendown()
color("yellow")
begin_fill()
for i in range(5):
    forward(30)
    right(144)
end_fill()

# Message
penup()
goto(-130, -150)
color("red")
write("MERRY CHRISTMAS", font=("Arial", 20, "bold"))

hideturtle()

Above is the python code to draw christmas tree you can copy the code and paste it in a python file and run it or you can use an online compiler to run.

As soon as you run it will open a new window and it will start to draw a christmas tree after finishing. Below is the output you should get.

Christmas tree in python output

You don’t have to install any libraries because the library we use turtle comes installed when we install python, but if you get any errors you can use the below command to install the library.


pip install turtle

Paste this command in the command prompt or terminal to install the turtle library in your project.

Summary

This was the tutorial to draw christmas tree in python. I hope you ran this program successfully without errors. You should not get any errors if you follow the steps correctly.

Do wish your friends a merry christmas by using this python program they will surely get surprised by it, specially if your friend is a programmer.

Here are some more python guides that might interest you:

I hope you found what you were looking for from this tutorial. If you want more python tutorials like this, do join our Telegram channel for future updates.

Thanks for reading, Merry Christmas 🙂