How to draw color filled shapes in Python Turtle?

Follow the below steps to draw filled shape with the desired color-

  1. Choose the fill color by calling fillcolor() function and pass the color name or color in the #RRGGBB format.
  2. After step 1, you must call begin_fill() and then start drawing using Turtle functions. Once you are done with the drawing, call end_fill() function to fill the drawn figure with the selected color.

Draw color filled square in Python Turtle

#Python program to draw color filled square in turtle programming
import turtle

t = turtle.Turtle()
t.fillcolor('blue')
t.begin_fill()
for i in range(4):
  t.forward(150)
  t.right(90)
t.end_fill()

Output of the above program

Color filled square in Python Turtle

Draw color filled triangle in Python Turtle

#Python program to draw color filled triangle in turtle programming
import turtle

t = turtle.Turtle()
t.fillcolor('#FFA500')
t.begin_fill()
for i in range(4):
  t.forward(150)
  t.right(-120)
t.end_fill()

Output of the above program

Color filled triangle in Python Turtle

Draw color filled star in Python Turtle

#Python program to draw color filled star in turtle programming
import turtle

t = turtle.Turtle()
t.fillcolor('orange')
t.begin_fill()
for i in range(5):
  t.forward(150)
  t.right(144)
t.end_fill()

Output of the above program

Color filled star in Python Turtle

Draw color filled hexagon in Python Turtle

#Python program to draw color filled hexagon in turtle programming
import turtle

t = turtle.Turtle()
t.fillcolor('orange')
t.begin_fill()
for i in range(6):
  t.forward(150)
  t.right(60)
t.end_fill()

Output of the above program

Color filled hexagon in Python Turtle

Draw color filled circle in Python Turtle

#Python program to draw color filled circle in turtle programming
import turtle

t = turtle.Turtle()
t.fillcolor('orange')
t.begin_fill()
t.circle(100)
t.end_fill()

Output of the above program

Color filled circle in Python Turtle

Recommended Posts