# Draw colored filled shapes using Python Turtle

In this Python tutorial, we will learn how to draw colored filled shapes using Python turtle with a few examples and also we will cover these topics:

• How to draw the colored filled shapes using Python turtle?
• How to change the screen color using Python turtle?
• How to draw colored filled half-circle in python turtle
• Draw colored filled circle using Python turtle
• How to draw a colored filled oval in python turtle
• Draw colored filled square using Python turtle
• Draw colored filled rectangle using Python turtle
• Draw colored filled triangle using Python turtle
• Draw colored filled star using Python turtle
• Draw colored filled hexagon using Python turtle
• Draw filled circle with a different color using Python turtle
• Program to draw a chessboard using Python turtle
• Draw a tic tac toe board using Python turtle
• Program to draw a car using Python using turtle
• Python turtle draw letters
• Draw rainbow benzene using python turtle
• How to create a brick wall in python turtle

If you are new to Python turtle, then check out Turtle programming in Python.

## How to draw colored filled shapes in python turtle?

Let’s understand the below steps how to draw the colored filled shapes using Python turtle with desired color-

• As we know turtle is the inbuilt module in python and it provides drawing using a screen and turtle(pen).
• To fill the desired colors in the shapes drawn by the turtle, we have some functions.
• We will use the function called fillcolor(), and we have to pass the color name or color in the #RRGGBB format. R, G, and B are the hexadecimal numbers (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F)
• Now, we have to call the function begin_fill() this function tells the turtle that all the upcoming closed objects need to fill with the given colors.
• And once, we are done with the drawing, call end_fill() function. This function tells the turtle to stop filling the upcoming objects.

## How to change screen color using Python turtle?

• We have already seen that by default turtle always opens up the screen with a white background. But let us see how to change screen color using turtle in Python.
• To change the color of the screen at any time first, we need to import turtle, then we can use the command “turtle.bgcolor(*args)”.
• The above method is used to set the background color of the turtle screen.

Example:

``````import turtle
turtle.bgcolor("green")
turtle.done()``````

In the below output, we can see the screen color is changed to the desired green color in the new drawing board.

## How to draw colored filled half-circle in python turtle

• Firstly, we need to import turtle, then we can create the turtle pen by declaring “tr = turtle.Turtle().
• We will use the function called tr.color(), and then we can set the color by using “tr.color(‘black’).
• Now, we have to call the function tr.begin_fill() this function will start filling the color inside the half-circle. Also, the circle is of radius 130 pixels and halfcircle 180 degrees.
• And once, we are done with the drawing, call the tr.end_fill() function. This function tells the turtle to end the filling of the color.

Example:

``````import turtle
tr = turtle.Turtle()
tr.color("black")
tr.begin_fill()
tr.circle(130,180)
tr.end_fill()
tr.hideturtle()
turtle.done()``````

In this output, we can see the colored filled half-circle is drawn on the new drawing board. It draws the circle of radius 130 pixels and halfcircle 180 degrees with black color filled inside. You can refer to the below screenshot.

## Draw colored filled circle in Python turtle

Let’s draw a colored filled circle in python using turtle in Python.

• Firstly, we need to import turtle, then we can create the turtle pen by declaring “tr = turtle.Turtle().
• We will use the function called fillcolor(), and then we can set the color by using “tr.fillcolor(‘black’).
• Now, we have to call the function tr.begin_fill() this function will start filling the color inside the circle.
• And once, we are done with the drawing, call the tr.end_fill() function. This function tells the turtle to end the filling of the color.

Example:

``````import turtle
tr = turtle.Turtle()
tr.fillcolor('black')
tr.begin_fill()
tr.circle(100)
tr.end_fill()
turtle.done()``````

In this output, we can see the colored filled circle is drawn on the new drawing board. It draws the circle of radius of 100 units with black color filled inside. You can refer to the below screenshot.

## How to draw a colored filled oval in python turtle

• Firstly, we need to import turtle, then we can create the turtle pen by declaring “tr = turtle.Turtle().
• The tr.color() is used to return or fill color and tr.shape() is used to set turtle shape with the given shape.
• Now, we have to call the function tr.begin_fill() this function will start filling the color inside the circle.
• And once, we are done with the drawing, call the tr.end_fill() function. This function tells the turtle to end the filling of the color.

Example:

``````import turtle
tr = turtle.Turtle()
tr.color("black")
tr.shape("circle")
tr.begin_fill()
tr.shapesize(10,5,2)
tr.end_fill()
turtle.done()``````

In this output, we can see the colored filled oval is drawn on the new drawing board. The tr.shapesize(10,5,2) is used to draw the oval, and 10 is the width, 5 is the length, and 2 is the outline for the oval.

## Draw colored filled square in Python turtle

Let us discuss, how to draw colored filled square using Python turtle.

• Firstly, we need to import turtle, then we can create the turtle pen by declaring “tr = turtle.Turtle().
• Here, we will use the fillcolor() function, and then we can set the color by using “tr.fillcolor(‘red’).
• Now, we will call the function tr.begin_fill() this function will start filling the color inside the square.
• For drawing the square we have used the forward() and right() method.
• And once, we are done with the filling of the color, call the tr.end_fill() function. This function tells the turtle to end the filling of the color.

Example:

``````import turtle
tr = turtle.Turtle()
tr.fillcolor('Red')
tr.begin_fill()
for i in range(4):
tr.forward(150)
tr.right(90)
tr.end_fill()
turtle.done()``````

In this output, we can see that the color is filled inside the square in the new drawing board. You can refer to the below screenshot.

## Draw colored filled rectangle in Python turtle

Now, we will see how to draw a colored filled rectangle using Python turtle.

• Firstly, import turtle module, then we can create the turtle pen by declaring “tr = turtle.Turtle().
• Here, we will use the fillcolor() function, and then we can set the color by using “tr.fillcolor(‘orange’).
• Now, we will call the function tr.begin_fill() this function will start filling the color inside the rectangle.
• For drawing the rectangle we have used for loop, and the forward() and right() method.
• And once, we are done with the filling of the color, call the tr.end_fill() function. This function tells the turtle to end the filling of the color.

Example:

``````import turtle
tr = turtle.Turtle()
tr.fillcolor('orange')
tr.begin_fill()
for i in range(2):
tr.forward(250)
tr.right(90)
tr.forward(150)
tr.right(90)
tr.end_fill()
turtle.done()``````

In this output, we can see that the orange color is filled inside the rectangle in the new window. You can refer to the below screenshot.

## Draw colored filled triangle in Python turtle

Let us see how to draw colored filled triangle using Python turtle.

• Firstly, import turtle module, then we can create the turtle pen by declaring “tr = turtle.Turtle().
• Here, we will use the fillcolor() function, and then we can set the color by using “tr.fillcolor(‘green’).
• Now, we will call the function tr.begin_fill() this function will start filling the color inside the triangle.
• We have used for loop and also the forward() and left() method is used to draw a triangle.
• And once, we are done with the filling of the color, call the tr.end_fill() function. This function tells the turtle to end the filling of the color.

Example:

``````import turtle
tr = turtle.Turtle()
tr.fillcolor('green')
tr.begin_fill()
for i in range(3):
tr.forward(200)
tr.left(120)
tr.end_fill()
turtle.done()``````

In this output, we can see that the green color is filled inside the triangle, and it will appear in the new window. You can refer to the below screenshot.

## Draw colored filled star using Python turtle

Let us see how to draw colored filled star in Python using Turtle.

• Firstly, import turtle module, then we can create the turtle pen by declaring “tr = turtle.Turtle().
• Here, we will use the fillcolor() function, and then we can set the color by using “tr.fillcolor(‘purple’).
• Now, we will call the function tr.begin_fill() this function will start filling the color inside the star.
• We have used for loop and also the forward() and left() method is used for drawing the star.
• And once, we are done with the filling of the color, call the tr.end_fill() function. This function tells the turtle to end the filling of the color.

Example:

``````import turtle
tr = turtle.Turtle()
tr.fillcolor('purple')
tr.begin_fill()
for i in range(5):
tr.forward(250)
tr.left(144)
tr.end_fill()
turtle.done()``````

In this output, we can see that the purple color is filled inside the star, and it will appear in the new window.

## Draw colored filled hexagon in Python turtle

Let us see how to draw colored filled hexagon using Python turtle.

• Firstly, import turtle module, then we can create the turtle pen by declaring “tr = turtle.Turtle().
• Here, we will use the fillcolor() function, and then we can set the color by using “tr.fillcolor(‘violet’).
• Now, we will call the function tr.begin_fill() this function will start filling the color inside the hexagon.
• We have used for loop and, also the forward() and left() method is used for drawing the hexagon.
• And once, we are done with the filling of the color, call the tr.end_fill() function. This function tells the turtle to end the filling of the color.

Example:

``````import turtle
tr = turtle.Turtle()
tr.fillcolor('violet')
tr.begin_fill()
for i in range(6):
tr.forward(120)
tr.left(60)
tr.end_fill()
turtle.done()``````

In this output, we can see that violet color is filled inside the hexagon in the new window. You can refer to the below screenshot.

## Draw filled circle with a different color using python turtle

Here, we will see how to fill different colors in circle using Python turtle.

• Firstly, import turtle module, then we can create the turtle pen by declaring “tr = turtle.Turtle().
• Here, we have created a list of different colors which is “list = [“violet”,”blue”,”red”,”green”]”.
• Also, we have used the goto() method to move some distance.
• The for loop will iterate 4 times to draw a 4 circle.
• Now, we have to call the function tr.begin_fill() this function will start filling the color inside the circle.
• To draws the circle of radius of 50 we have used tr.circle() function.

Example:

``````import turtle
tr = turtle.Turtle()
list = ["violet","blue","red","green"]
tr.up()
tr.goto(200,0)
for i in range(4):
tr.down()
tr.begin_fill()
tr.fillcolor(list[i])
tr.circle(50)
tr.end_fill()
tr.up()
tr.backward(100)
tr.hideturtle()
turtle.done()``````

In this output, we can see that the different color is filled inside the circle in the new window. You can refer to the below screenshot.

## Program to draw a chessboard in python turtle

For drawing chess board in Python using turtle, we will use the below steps:

• Firstly, we have to import the turtle module, and then we will create a screen object by using “scr = turtle.Screen()”.
• For creating a turtle object we have used “tr = turtle.Turtle()”.
• Now, we will define a method to draw a square using the for loop to iterate in the given range. The tr.forward(20) is used for moving the turtle in a forward direction by 20 units and tr.left(90) is used for turning the turtle in 90 degrees. This statement will be repeated 3 times to get the remaining boundaries of a chessboard.
• To set the screen we have used the scr.setup() method in which widht=600 and height=600. The tr.speed(100) is the turtle object speed, you can also change the speed accordingly.
• Then the other for loop will control the drawing of a square in a row. So, we have set the position for every row using “tr.setpos(0, 20*i)”.
• Again, we have used the for loop for 8 times and the if condition for alternative color which is “black” and “white”. Also, tr.fillcolor(col) will start filling with the given color and tr.end_fill() will stop filling.
• In the end, we have used tr.hideturtle() to hide the turtle.

Example:

``````import turtle
scr = turtle.Screen()
tr = turtle.Turtle()
def draw():
for i in range(4):
tr.forward(20)
tr.left(90)
tr.forward(20)
if __name__ == "__main__":
scr.setup(600, 600)
tr.speed(100)
for i in range(8):
tr.up()
tr.setpos(0, 20*i)
tr.down()
for j in range(8):
if(i + j)%2 == 0:
col = 'black'
else:
col = 'white'
tr.fillcolor(col)
tr.begin_fill()
draw()
tr.end_fill()
tr.hideturtle()
turtle.done()``````

In this output, we can see that the chessboard is drawn in the new window. You can refer to the below screenshot.

## Draw a tic tac toe board using Python turtle

Let us see how to draw a tic tac toe board in Python turtle.

• Firstly, we have to import the turtle module, and then we will create a screen object by using “scr = turtle.Screen()”.
• For creating a turtle object we have used “tr = turtle.Turtle()”.
• Then set up the turtle color to “blue” and the width to “3”.
• Here, I have manually set the speed of the turtle to “2”.
• So, for drawing the tic tac toe board first we have to make an outer square and for loop is used to iterate. The “tr.forward(300)” is used for moving the turtle in a forward direction by 300 units and “tr.left(90)” is used for turning the turtle in 90 degrees.
• For inner lines of a square, I have used the method penup(), goto(), and pendown().

Example:

``````import turtle
scr = turtle.Screen()
tr = turtle.Turtle()
tr.color("blue")
tr.width("3")
tr.speed(2)
for i in range(4):
tr.forward(300)
tr.left(90)
tr.penup()
tr.goto(0,100)
tr.pendown()
tr.forward(300)
tr.penup()
tr.goto(0,200)
tr.pendown()
tr.forward(300)
tr.penup()
tr.goto(100,0)
tr.pendown()
tr.left(90)
tr.forward(300)
tr.penup()
tr.goto(200,0)
tr.pendown()
tr.forward(300)
tr.hideturtle()
turtle.done()``````

In this output, we can see the tic tac toe board in the new window. You can refer to the below screenshot.

## Program to draw a car in python turtle

Let see how to draw a car in Python using turtle

• For drawing the car in a python turtle, we have to think about the shapes and structure of the car. The upper body of the car will be a rectangle, the tyres can be drawn as a circle and the window and roof are similar to a trapezoid.
• Firstly, we have to import the turtle module, and then we will create a turtle object “tr = turtle.Turtle()”.
• Now, we will draw a rectangular upper body of a car by using “tr.color(‘#f62b35’)” and “tr.fillcolor(‘#f62b35’)” is used for filling the color in car.
• Also, we have used the penup(), goto(), pendown(), setheading() methods for drawing a car.
• To draw the tyres we have used “tr.circle(20)” function and for filling the color in tyres we have used “tr.color(‘#000000’)” and “tr.fillcolor(#000000′)”.

Example:

``````import turtle
tr = turtle.Turtle()
tr.color('#f62b35')
tr.fillcolor('#f62b35')
tr.penup()
tr.goto(0,0)
tr.pendown()
tr.begin_fill()
tr.forward(370)
tr.left(90)
tr.forward(50)
tr.left(90)
tr.forward(370)
tr.left(90)
tr.forward(50)
tr.left(90)
tr.end_fill()
tr.penup()
tr.goto(100,50)
tr.pendown()
tr.forward(70)
tr.forward(100)
tr.forward(70)
tr.penup()
tr.goto(200, 50)
tr.pendown()
tr.forward(49.50)
tr.penup()
tr.goto(100, -10)
tr.pendown()
tr.color('#000000')
tr.fillcolor('#000000')
tr.begin_fill()
tr.circle(20)
tr.end_fill()
tr.penup()
tr.goto(300, -10)
tr.pendown()
tr.color('#000000')
tr.fillcolor(#000000')
tr.begin_fill()
tr.circle(20)
tr.end_fill()
tr.hideturtle()
turtle.done()``````

In this output, we can see the colored filled car in the new window. You can refer to the below screenshot.

## Python turtle draw letters

In this example we will see how to draw letters in python turtle

• Firstly, import turtle module, then we can create the turtle pen by declaring “tr = turtle.Turtle().
• Here, we have used tr.color(“Blue”) and tr.width(3) is used for line thickness.
• For printing the letter “G” we have to use for loop to make a semicircle. The backward() is used to move the pen in the backward direction by x unit.
• The left() is used to rotate the pen in the antilock direction by an angle of x.

Example:

``````import turtle
ws = turtle.Screen()
tr = turtle.Turtle()
tr.color("Blue")
tr.width(3)
for x in range(180):
tr.backward(1)
tr.left(1)
tr.right(90)
tr.forward(50)
tr.right(90)
tr.forward(30)
tr.right(90)
tr.forward(50)
turtle.done()``````

In this output, we can see that letter “G” is drawn in the new window. You can refer to the below screenshot.

## How to write text in python turtle

• Firstly, import turtle module, then we can create the turtle pen by declaring “tr = turtle.Turtle().
• Here, we have used tr.color(‘red’). The style=(fontname, fontsize,fonttype) is used to set the text in the given way.
• The turtle.write() function is used to write text at the current turtle position.
• To hide the turtle we have used “tr.hideturtle()”

Example:

``````import turtle
tr = turtle.Turtle()
tr.color('red')
style = ('courier',30,'italic')
tr.write('Welcome to Python Turtle',font=style,align='center')
tr.hideturtle()
turtle.done()``````

In this output, we can see how the text is written in the new window. You can refer to the below screenshot.

## Draw rainbow benzene using python turtle

• Firstly, import turtle module, then we can create the turtle object by declaring “tr = turtle.pen().
• We set the screen background color as ‘black’, and the speed of the turtle is ‘0’ which is the fastest.
• After that for loop is used and the range is 180.
• The tr.pencolor(colors[x%6]) is used for color in each step.
• Here, tr.width(x/100 + 1) is used for increasing the width and the rotation will be 59 degrees on the left.

Example:

``````import turtle
colors = ['purple', 'indigo', 'blue', 'green', 'yellow', 'orange']
tr = turtle.pen()
turtle.bgcolor('black')
tr.speed(0)
for x in range(180):
tr.pencolor(colors[x%6])
tr.width(x/100 + 1)
tr.forward(x)
tr.left(59)
turtle.done()``````

In this output, we can see the rainbow benzene in the new window. You can refer to the below screenshot.

## How to create a brick wall in python turtle

Let see how to create a brick wall in python turtle

• To create a brick wall in python turtle, we have to import the turtle and screen first.
• Here, Cursor_Size = 20 for drawing the brick. The scr.setup(600, 600) is used to setup the screen size.
• scr.setworldcoordinates(0, 0, 12, 24) is used to setup the user define coordinate based on bricks.
• turtle.shapesize(25 / Cursor_Size, 50 / Cursor_Size, 5) it is used to turn cursor into brick.

Example:

``````from turtle import Screen, Turtle
Cursor_Size = 20
scr = Screen()
scr.setup(600, 600)
scr.setworldcoordinates(0, 0, 12, 24)
scr.bgcolor('black')
turtle = Turtle('square', visible=False)
turtle.penup()
turtle.speed(10)
turtle.color('black', 'red')
turtle.shapesize(25 / Cursor_Size, 50 / Cursor_Size, 5)
for y in range(24):
turtle.setposition(-0.5 * (y % 2), y + 0.3)
for x in range(13):
turtle.stamp()
turtle.forward(1)
scr.mainloop()``````

In this output, we can see that the brick wall is created in the new window. You can refer to the below screenshot.

You may like the following Python tutorials:

In this tutorial we have learned how to draw colored filled shapes in python using turtle and also we saw Turtle programming in Python, also we have covered these topics:

• How to draw the colored filled shapes in python turtle?
• How to change the screen color in python turtle?
• How to draw colored filled half-circle in python turtle
• Draw colored filled circle in python turtle
• How to draw a colored filled oval in python turtle
• Draw colored filled square in python turtle
• Draw colored filled rectangle in python turtle
• Draw colored filled triangle in python turtle
• Draw colored filled star in python turtle
• Draw colored filled hexagon in python turtle
• Draw filled circle with a different color using python turtle
• Program to draw a chessboard in python turtle
• Draw a tic tac toe board in python turtle
• Program to draw a car in python turtle
• Python turtle draw letters
• How to write text in python turtle
• Draw rainbow benzene using python turtle
• How to create a brick wall in python turtle