Pythondex
Turtle Python Programs

Draw YouTube Logo Using Python

Last updated July 3, 2023 by Jarvis Silva

Want to know how to draw YouTube logo using python, then you are at the right place. Today in this tutorial I will show you step by step how to create this program.

YouTube is one of the most popular video platform, You can find and learn anything from YouTube so today I have decided to create a tutorial on drawing its logo using python.

We will use the turtle module for creating this program in python, Turtle is a GUI library with the help of this library you can draw anything in python. 

Python Code To Draw Youtube Logo


import turtle as t

t.pencolor('red')
t.fillcolor('red')
t.begin_fill()
t.penup()
t.goto(150,100)
t.left(180)
t.right(3)
t.pendown()

t.Screen().bgcolor('yellow')

for i in  range(10):
    t.forward(30)
    t.left(0.5)
    
for i in range(65):
    t.forward(1)
    t.left(1)

for i in range(6):
    t.forward(2)
    t.left(2)

for i in range(8):
    t.forward(10)
    t.left(1)

for i in range(10):
    t.left(1)
    t.forward(10)

for i in range(6):
    t.forward(2)
    t.left(2)

for i in range(65):
    t.forward(1)
    t.left(1)

t.left(3)

for i in  range(10):
    t.forward(30)
    t.left(0.5)

for i in range(65):
    t.forward(1)
    t.left(1)

for i in range(6):
    t.forward(2)
    t.left(2)

for i in range(8):
    t.forward(10)
    t.left(1)

for i in range(10):
    t.left(1)
    t.forward(10)

for i in range(65):
    t.forward(1)
    t.left(1)

for i in range(6):
    t.forward(2)
    t.left(2)

t.end_fill()
t.pencolor('white')
t.penup()
t.goto(0,0)
t.goto(-27,13)
t.pendown()
t.fillcolor('white')
t.begin_fill()
t.left(93)

for i in range(3):
    t.forward(100)
    t.left(120)

t.end_fill()
t.done()

Above is the python code for drawing the YouTube logo, below is an short and simple explaination of how this code works:

  • The code imports all the functions and classes from the turtle module.
  • The drawing speed is set to 10 using the speed() function.
  • The pen color is set to a shade of blue (#0270d6) using the color() function.
  • The screen background color is set to yellow using the bgcolor() function.
  • The pen is lifted off the drawing surface using the penup() function, and the turtle’s position is set to (0, 150) using the goto() function.
  • The pen is lowered onto the drawing surface using the pendown() function.
  • The turtle starts filling a shape using the begin_fill() function.
  • A loop is executed four times, where the turtle moves forward by 300 units and then turns 90 degrees to the left while making a partial circle with a radius of -50 units. This creates a square-like shape with rounded corners.
  • The turtle moves forward by 150 units to complete the shape and then ends the fill using the end_fill() function.
  • The pen color is changed to white using the color() function, and a new shape is drawn by manipulating the turtle’s position and orientation. This shape consists of a combination of straight lines, curves, and angles. The fill color is set to white using the begin_fill() function, and the shape is filled. The turtle hides using the hideturtle() function, and the drawing is completed by calling done(), which closes the turtle graphics window.

Now you have the code, but there is one last thing you need to do as I have said I have used the turtle library for this program so you might need to install it if you get any errors like turtle module not found so use below command to install turtle.


pip install turtle

Now to run this program you need to have python installed on your computer, If you don’t have then follow this guide: Install and setup python on your computer or use this online python compiler.

After you run the program and it will open a new window and it will start drawing the YouTube Logo and below is the finished drawing of the logo.

Youtube Logo Drawing

As you can see, we successfully drew the YouTube logo using python turtle, I hope you were able to run this program successfully. 

Want more amazing turtle tutorials like this check out this: Awesome Python Turtle Codes.

Here are some more python drawing tutorials for you:

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

Thanks for reading, have a nice day 🙂