Python – Draw “GFG” logo using Turtle Graphics
Prerequisites: Turtle Programming in Python
Turtle is a Python feature like a drawing board, which let us command a turtle to draw all over it! We can use many turtle functions which can move the turtle around. Turtle comes into the turtle library. The turtle module can be used in both object-oriented and procedure-oriented ways.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
Some of the commonly used methods are:
- forward(length): moves the pen in the forward direction by x unit.
- backward(length): moves the pen in the backward direction by x unit.
- right(angle): rotate the pen in the clockwise direction by an angle x.
- left(angle): rotate the pen in the anticlockwise direction by an angle x.
- penup(): stop drawing of the turtle pen.
- pendown(): start drawing of the turtle pen.
In this article, we will be drawing the logo of GeeksforGeeks which looks like this –
- Importing Turtle.
- Forming a window screen with size and color.
- Then start to draw the logo:
- Form ‘C’ in the backward direction
- line 90 degree up
- line 90 degree right
- line 90 degree down
- Form ‘C’ in forwarding direction
Below is the implementation.
# importing turtle for graphics import turtle # Forming the window screen tut = turtle.Screen() # background color green tut.bgcolor("White") # object pen = turtle.Turtle() #speed of pen pen.speed(10) # object color pen.color("Green") # object width pen.width(10) tut = turtle.Screen() # Code for symbol # backward C for x in range(180): pen.forward(1) pen.right(1) # up pen.right(90) pen.forward(50) # right pen.right(90) pen.forward(130) # down pen.right(90) pen.forward(50) pen.left(90) # forward C for x in range(180): pen.backward(1) pen.right(1) turtle.done()