Draw Color Filled Shapes in Turtle Python (original) (raw)

Last Updated : 12 Jul, 2025

In Python's Turtle module, we can create visually appealing graphics by drawing shapes and filling them with colors. This allows us to design colorful patterns, logos, and illustrations. Let's explore how to draw and fill different shapes using Turtle in Python.

Steps to draw color-filled shapes in Python

**1. **Importing the Turtle Module

import turtle

**2. Creating the Screen and Turtle Object: We need to create a screen and a turtle object to start drawing.

screen = turtle.Screen()
t = turtle.Turtle()

**3. Choosing the Color: We can set the color for the shape’s outline and its fill using the color() method. For example:

t.color("blue", "yellow")

**4. Drawing Shapes: To draw shapes, we use methods like forward(), left(), right(), etc., to move the turtle around the screen. The begin_fill() method is called before the turtle starts drawing, and end_fill() is called when the shape is completed.

Examples of Color Filled Shapes in Python

1. Drawing Color Filled Square:

Python `

import turtle

t = turtle.Turtle()

s = int(input("side of the square: "))

col = input("color name or hex value of color(#RRGGBB): ")

t.fillcolor(col)

t.begin_fill()

drawing the square of side s

for _ in range(4): t.forward(s) t.right(90)

t.end_fill()

`

**Input

200
green

**Output

turtleSquare

**Explanation:

2. Drawing Color Filled Triangle:

Python `

import turtle

t = turtle.Turtle()

s = int(input("side of the triangle: "))

col = input("color name or hex value of color(#RRGGBB): ")

t.fillcolor(col)

t.begin_fill()

drawing the triangle of side s

for _ in range(3): t.forward(s) t.right(-120)

t.end_fill()

`

**Input

200
red

**Output

**Explanation:

3. Drawing Color Filled Hexagon:

Python `

import turtle

t = turtle.Turtle()

s = int(input("side of the hexagon: "))

col = input("color name or hex value of color(#RRGGBB): ")

t.fillcolor(col)

t.begin_fill()

drawing the hexagon of side s

for _ in range(6): t.forward(s) t.right(-60)

t.end_fill()

`

**Input

100
#113300

**Output

**Explanation:

4. Drawing Color Filled Star:

Python `

import turtle

t = turtle.Turtle()

s = int(input("side of the star: "))

col = input("color name or hex value of color(#RRGGBB): ")

t.fillcolor(col)

t.begin_fill()

drawing the star of side s

for _ in range(5): t.forward(s) t.right(144)

t.end_fill()

`

**Input

200
#551122

**Output

turtleStar

**Explanation:

5. Drawing Color Filled Circle:

Python `

import turtle

t = turtle.Turtle()

r = int(input("radius of the circle: "))

col = input("color name or hex value of color(# RRGGBB): ")

t.fillcolor(col)

t.begin_fill()

drawing the circle of radius r

t.circle(r)

t.end_fill()

`

**Input

100
blue

**Output

turtleCircle

**Explanation:

**Related Articles: