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()andend_fill()You can fill a shape with
What Is Color Fill?
Analogy: A Coloring Book
Think about a coloring book!
- Pick a colored pencil → Choose what color to use
- "Starting here!" → Mark the starting point
- Draw along the outline → Draw the shape
- "Up to here!" → When you finish, it colors in automatically!
🎨 The turtle works the same way!
Three Commands
1. fillcolor() - Choose a color
2. begin_fill() - Start filling
3. end_fill() - Finish filling
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
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 beforebegin_fill()→ Drawing right beforeend_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!
🎯 Quiz
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!