Skip to content

E1. Color Fill Basics


🎯 Learning Goals

By the end of this lesson, you'll be able to:

  • fillcolor()You can set a color with
  • begin_fill()and end_fill()You can fill a shape with

What Is Color Fill?

Analogy: A Coloring Book

Think about a coloring book!

  1. Pick a colored pencil → Choose what color to use
  2. "Starting here!" → Mark the starting point
  3. Draw along the outline → Draw the shape
  4. "Up to here!" → When you finish, it colors in automatically!

🎨 The turtle works the same way!

fillcolor("blue")  → Pick a colored pencil
begin_fill()       → "Starting here!"
(draw the shape)   → Draw the outline
end_fill()         → "Up to here!" + automatic coloring

Three Commands

1. fillcolor() - Choose a color

t.fillcolor("blue")   # Set to blue
t.fillcolor("red")    # Set to red

2. begin_fill() - Start filling

t.begin_fill()  # "I'll start coloring here!"

3. end_fill() - Finish filling

t.end_fill()  # "Up to here! Now color it in!"

Colors You Can Use

Color English Code
🔴 Red red "red"
🟢 Green green "green"
🔵 Blue blue "blue"
🟡 Yellow yellow "yellow"
🟠 Orange orange "orange"
🟣 Purple purple "purple"

Step-by-Step Example

Step 1: A rectangle with no color

import turtle

t = turtle.Turtle()

# Draw a rectangle
for _ in range(4):
    t.forward(80)
    t.right(90)

Result: a rectangle with only an outline ⬜


Step 2: Adding color

import turtle

t = turtle.Turtle()

t.fillcolor("blue")   # 1. Choose blue
t.begin_fill()        # 2. Start filling!

for _ in range(4):    # 3. Draw the rectangle
    t.forward(80)
    t.right(90)

t.end_fill()          # 4. Finish filling!

Result: a rectangle filled with blue 🟦


Code Comparison

No color With color
for _ in range(4): t.fillcolor("blue")
t.forward(80) t.begin_fill()
t.right(90) for _ in range(4):
t.forward(80)
t.right(90)
t.end_fill()

💡 Key point

  • fillcolor() → Drawing before
  • begin_fill() → Drawing right before
  • end_fill() → Drawing right after

🎯 Mission: Make It Along

Mission 1: Draw a blue rectangle

Run the code to see the blue rectangle!


Mission 2: Change the color

"blue"Change it to a different color!


Mission 3: Fill in the blanks

Fill in the blanks to complete the red rectangle!

Check answers
t.fillcolor('red')
t.begin_fill()
# ... draw the rectangle ...
t.end_fill()

🎯 Quiz

Quiz: The Correct Order
What order do you need to fill a shape with color?
Show Answer

Answer: C) begin_fill → draw → end_fill

a sandwichThink of it like:

  • begin_fill() = top bun 🍞
  • Draw the shape = the filling 🥬
  • end_fill() = bottom bun 🍞

Color fill practice:

  • Choose a color: t. ("blue")
  • Start filling: t. ()
  • Finish filling: t. ()

⚠️ Try Breaking It (Let's Break It!)

In the code below, the color doesn't fill in. What's the problem?

import turtle

t = turtle.Turtle()
t.fillcolor("blue")

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

t.end_fill()  # The color doesn't fill in!
Show Hint

end_fill() Something seems to be missing before this...

Show Answer

begin_fill()is missing!

t.fillcolor("blue")
t.begin_fill()  # ← This line was missing!

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

t.end_fill()

Remember: begin_fill()and end_fill()is always come in a pairWith this!


🧩 Key Takeaways

What you learned in this lesson:

Command Description
t.fillcolor(color) Choose the fill color
t.begin_fill() Start filling
t.end_fill() Finish filling

Order: fillcolor → begin_fill → draw → end_fill

Preview of the Next Lesson

In the next lesson, we'll learn Adding color to a function—learn how!

def draw_bar(t, height, color):
    t.fillcolor(color)  # Use color inside the function
    ...