# Drawing Colour Filled Shapes in Turtle - Python

Python has a built-in module called turtle. It offers drawing with a cardboard screen and a turtle (pen). We must move the turtle in order to draw anything on the screen. There are other functions, such as forward() and reverse(), to move the turtle.

The turtle is both the name of the library and the name of the on-screen pen we use to sketch with. In conclusion, the Python turtle library makes it engaging and intriguing for new programmers to learn Python. Turtle is generally used to introduce kids to computers.

## How to draw colour filled shapes in Turtle - Python ?

Let's examine the subsequent phases of how to use a Python turtle to draw the coloured filled shapes in the appropriate colour. Turtle has three functions to fill the colours in the shapes it has drawn :

• fillcolor() : This function aids in selecting the colour to fill the shape. It uses the colour name or hex value provided as an input parameter to fill the following closed topographical objects with the specified colour. Basic colour names include red, blue, green, and orange.
The hex value of a colour is a string of hexadecimal numbers (beginning with "#"), such as #RGGRBG. The three hexadecimal numbers are R, G, and B.
• begin_fill() : instructs Turtle that the selected colour must be used to fill any upcoming closed graphical objects.
• End_fill() : instructs turtle to halt filling impending closed graphical objects.

So let's begin :

### Using Python turtle for drawing a colour filled half-circle :

The turtle pen can then be made by declaring "ttl = turtle.Turtle" after first importing turtle.

To set the colour, we will first use the ttl.color() function and then ttl.color("pink").

The function ttl.begin_fill() must now be called in order to begin filling the half-circle with colour. The circle's radius is 90 pixels, and its circumference is 180 degrees.

Once the drawing is complete, call the ttl.end_fill() function. This command instructs the turtle to stop filling the colour in.

Lastly we hide the turtle using ttl.hideturtle().

### Complete code :

Output: Explanation :

The colour filled half-circle is drawn on a new drawing board, as can be seen in this output. It creates a circle with a radius of 90 pixels and a half-circle at an angle of 180 degrees that is filled with pink. You can take a look at the screenshot above.

### Using Python turtle for drawing a colour filled circle :

Let's use Python's turtle to create a circle that is filled with colour.

The turtle pen can then be made by declaring "ttl = turtle.Turtle" after first importing turtle.

To set the colour, we will first use the ttl.color() function and then ttl.color("red").

The function ttl.begin_fill() must now be called in order to begin filling the circle with colour. The circle's radius is 90 pixels.

Once the drawing is complete, call the ttl.end_fill() function. This command instructs the turtle to stop filling the colour in.

Lastly we hide the turtle using ttl.hideturtle().

### Complete code :

Output: Explanation :

The colour filled circle is drawn on a new drawing board, as can be seen in this output. It creates a circle with a radius of 90 pixels that is filled with red colour. You can take a look at the screenshot above.

### Using Python turtle for drawing a colour filled square :

Let's talk about how to draw a square with colour filled using a Python turtle.

The turtle pen can then be made by declaring "ttl = turtle.turtle" after first importing turtle.

Here, we'll use the fillcolor() function, after which we'll use "ttl.fillcolor("yellow") to set the colour.

The function ttl.begin_fill() will now be called, and it will begin filling the square with colour.

Here, we will use a for loop four times to draw each side using forward() and right() methods.

Call the ttl.end_fill() function once we have finished filling the colour. This command instructs the turtle to stop filling the colour in.

### Complete Code :

Output: Explanation :

The square in the current drawing board is filled with yellow colour in this output, as can be seen by the help of a for loop and various turtle library methods. You can take a look at the screenshot above.

### Using Python turtle for drawing a colour filled rectangle :

Let's talk about how to draw a rectangle with colour filled using a Python turtle.

The turtle pen can then be made by declaring "ttl = turtle.turtle" after first importing turtle.

Here, we'll use the fillcolor() function, after which we'll use "ttl.fillcolor("green") to set the colour.

The function ttl.begin_fill() will now be called, and it will begin filling the rectangle with colour.

Here, we will use a for loop 2 times to draw each side using forward() and right() methods, with one side as the length and the other side as the breadth of the rectangle.

Call the ttl.end_fill() function once we have finished filling the colour. This command instructs the turtle to stop filling the colour in.

### Complete Code :

Output: Explanation :

The rectangle in the current drawing board is filled with green colour in this output, as can be seen by the help of a for loop and various turtle library methods. You can take a look at the screenshot above.

### Using Python turtle for drawing a colour filled triangle :

Let's talk about how to draw a triangle with colour filled using a Python turtle.

The turtle pen can then be made by declaring "ttl = turtle.turtle" after first importing turtle.

Here, we'll use the fillcolor() function, after which we'll use "ttl.fillcolor("blue") to set the colour.

The function ttl.begin_fill() will now be called, and it will begin filling the triangle with colour.

Here, we will use a for loop three times to draw each side using forward() and left() methods.

Call the ttl.end_fill() function once we have finished filling the colour. This command instructs the turtle to stop filling the colour in.

### Complete Code :

Output: Explanation :

The triangle in the current drawing board is filled with blue colour in this output, as can be seen by the help of a for loop and various turtle library methods. You can take a look at the screenshot above.

### Using Python turtle for drawing a colour filled star :

Let's talk about how to draw a star with colour filled using a Python turtle.

The turtle pen can then be made by declaring "ttl = turtle.turtle" after first importing turtle.

Here, we'll use the fillcolor() function, after which we'll use "ttl.fillcolor("magenta") to set the colour.

The function ttl.begin_fill() will now be called, and it will begin filling the star with the colour.

Here, we will use a for loop five times to draw each side using forward() and right() methods, with right turn at an angle of 144 degrees.

Call the ttl.end_fill() function once we have finished filling the colour. This command instructs the turtle to stop filling the colour in.

### Complete Code :

Output: Explanation :

The star in the current drawing board is filled with magenta colour in this output, as can be seen by the help of a for loop and various turtle library methods. You can take a look at the screenshot above.

### Using Python turtle for drawing a colour filled Hexagon :

Let's talk about how to draw a hexagon with colour filled using a Python turtle.

The turtle pen can then be made by declaring "ttl = turtle.turtle" after first importing turtle.

Here, we'll use the fillcolor() function, after which we'll use "ttl.fillcolor("light green") to set the colour.

The function ttl.begin_fill() will now be called, and it will begin filling the hexagon with the colour.

Here, we will use a for loop six times to draw each side using forward() and right() methods, with right turn at an angle of 60 degrees.

Call the ttl.end_fill() function once we have finished filling the colour. This command instructs the turtle to stop filling the colour in.

### Complete Code :

Output: Explanation :

The hexagon in the current drawing board is filled with light green colour in this output, as can be seen by the help of a for loop and various turtle library methods. You can take a look at the screenshot above.

### Using Python turtle for drawing a colour filled Octagon :

Let's talk about how to draw a octagon with colour filled using a Python turtle.

The turtle pen can then be made by declaring "ttl = turtle.turtle" after first importing turtle.

Here, we'll use the fillcolor() function, after which we'll use "ttl.fillcolor("light blue") to set the colour.

The function ttl.begin_fill() will now be called, and it will begin filling the octagon with the colour.

Here, we will use a for loop eight times to draw each side using forward() and right() methods, with right turn at an angle of 45 degrees.

Call the ttl.end_fill() function once we have finished filling the colour. This command instructs the turtle to stop filling the colour in.

### Complete Code :

Output: Explanation :

The octagon in the current drawing board is filled with light blue colour in this output, as can be seen by the help of a for loop and various turtle library methods. You can take a look at the screenshot above.

## Conclusion :

To conclude, we learnt about the various methods like forward(), right(), left(), end_fill(), begin_fill() and color(). By the help of these method, we were able to construct various shapes and fill them with colours using the turtle Python library.

### Feedback   