Today, we will learn how to draw the letter ‘A’ using Python Turtle. We all know how to write the letter ‘A’ using pen and paper, but would it not be great if you had a turtle, who can take your commands and draw it for you in whatever size or color you want? This is what Python Turtle does. It is a python library used to create graphics, patterns, and shapes, but it can be used to draw almost anything.
This article has two parts, in the first part we will learn how to draw the letter ‘A’ in one dimension, and in the next part, we will learn to draw the letter ‘A’ in two dimensions.
Code for drawing letter ‘A’ in one-dimension
#Drawing letter 'A' in 1 dimension
#importing the module
import turtle
#creating a turtle object and assigning it to t
t = turtle.Turtle()
side=100 #side lengths of letter 'A'
#initially the turtle points towards right
t.left(60)
#the turtle pointer will take a 60 degree turn
t.forward(side)
#draw length of one side of 'A'
t.right(180-60)
#turtle take a 120 degree turn from current direction of turtle
#so that there is a 60 degree angle between two sides of 'A'
t.forward(side)
#this will draw another side
#this part is to draw the middle line across two sides of 'A'
t.penup()
t.right(180)
t.forward(side/2)
t.pendown()
t.left(60)
t.forward(side/2)
#it calls Tkinter’s mainloop function
#so that window will stay open until the user exits the program
turtle.done()
Output:
Since, we are done with the easy part, we are better equipped to go ahead and draw the letter ‘A’ in two-dimensions
Code for drawing letter ‘A’ in two-dimension
#Drawing letter 'A' in 2-dimension
#importing the module
import turtle
#creating a new turtle object and assigning it to t
t = turtle.Turtle()
#setting the size of letter A
outer_side=200
width=20 #width of letter as we will be drawing in 2 dimension
inner_side=outer_side-width
inner_triangle_side=inner_side/2 - 2*width
#part1, drawing the outer boundary
t.fillcolor("blue") #select the colour of letter
t.begin_fill() #starting point for filling colour
t.backward(width)
t.left(60) #this is to keep letter A at 60 degrees with respect to x-axis
t.forward(outer_side)
#at this point the turtle has drawn left side of outer boundary of 'A'
t.right(120)
t.forward(outer_side)
t.right(120)
t.forward(width)
#at this point of time, both sides of outer boundary of 'A' will be drawn
#now we will draw lower half of inner boundary of 'A'
t.right(60)
t.forward(inner_side/2)
t.left(60)
t.forward(inner_side/2 - width)
t.left(60)
t.forward(inner_side/2)
#at this point the lower half of inner boundary of 'A' will be drawn
t.end_fill() #this will fill the entire area inside the letter with blue colour
#part1, i.e., drawing the outer boundary is done
t.left(180)
t.penup()
#penup is used to move turtle to particular point without drawing anything
t.forward(inner_side/2 + width)
#part2, drawing inner triangle of 'A'
t.fillcolor("white")
#As we had filled 'A' with blue color, so keeping white color for inner triangle
t.begin_fill()
t.pendown()
t.forward(inner_triangle_side)
t.right(120)
t.forward(inner_triangle_side)
t.right(120)
t.forward(inner_triangle_side)
t.end_fill()
turtle.done()
Output:
So, we learned how to draw the letter ‘A’ using Python turtle, you can make changes in code to change color and increase/decrease the size of the letter. For better understanding, I suggest you run the program after every few lines to observe how it is working. Just remember to put turtle.done() at the end before running. Hope, you had fun going through this article.
Also Read:
- Radha Krishna using Python Turtle
- Drawing letter A using Python Turtle
- Wishing Happy New Year 2023 in Python Turtle
- Snake and Ladder Game in Python
- Draw Goku in Python Turtle
- Draw Mickey Mouse in Python Turtle
- Happy Diwali in Python Turtle
- Draw Halloween in Python Turtle
- Write Happy Halloween in Python Turtle
- Draw Happy Diwali in Python Turtle
- Extract Audio from Video using Python
- Drawing Application in Python Tkinter
- Draw Flag of USA using Python Turtle
- Draw Iron Man Face with Python Turtle: Tony Stark Face
- Draw TikTok Logo with Python Turtle
- Draw Instagram Logo using Python Turtle
- I Love You Text in ASCII Art
- Python Turtle Shapes- Square, Rectangle, Circle
- Python Turtle Commands and All Methods
- Happy Birthday Python Program In Turtle
- I Love You Program In Python Turtle
- Draw Python Logo in Python Turtle
- Space Invaders game using Python
- Draw Google Drive Logo Using Python
- Draw Instagram Reel Logo Using Python
- Draw The Spotify Logo in Python Turtle
- Draw The CRED Logo Using Python Turtle
- Draw Javascript Logo using Python Turtle
- Draw Dell Logo using Python Turtle
- Draw Spider web using Python Turtle