19 Sep turtle.fillcolor() function in Python
The turtle.fillcolor() function sets the fill color used when drawing filled shapes. This color is used when filling begins.
Syntax: turtle.fillcolor(*args)
Parameters: Can be a colorstring (e.g., “red”) or an RGB tuple (e.g., (0.2, 0.8, 0.55)).
Let us see an example to implement the turtle.fillcolor() function in Python:
Demo25.py
# turtle.fillcolor() function in Python
# Code by Studyopedia
import turtle
window = turtle.Screen()
t = turtle.Turtle()
t.fillcolor("red") # Set fill color to red
t.begin_fill()
for _ in range(4):
t.forward(100)
t.left(90)
t.end_fill()
window.exitonclick()
The following is the output:

In the above code, we followed the below steps:
- Import the module: import turtle loads Python’s turtle graphics library.
- Create the screen: window = turtle.Screen() opens the drawing window.
- Create the turtle: t = turtle.Turtle() creates the turtle (your pen).
- Set fill color: t.fillcolor(“red”) sets the interior color for filled shapes to red. Outline color is controlled separately by pencolor/color.
- Start filling: t.begin_fill() tells turtle to record the path you draw next so it can fill the enclosed shape.
- Draw the square loop:
- for _ in range(4): repeats the next two commands four times.
- t.forward(100) draws one side of length 100.
- t.left(90) turns 90° to form right angles.
- End filling: t.end_fill() fills the traced shape with the current fill color (red) and leaves the outline drawn.
- Close on click: window.exitonclick() keeps the window open until you click, then closes.
If you liked the tutorial, spread the word and share the link and our website, Studyopedia, with others.
For Videos, Join Our YouTube Channel: Join Now
Read More:
- OpenCV Tutorial
- Python Tutorial
- NumPy Tutorial
- Pandas Tutorial
- Matplotlib Tutorial
- Generative AI Tutorial
- LangChain Tutorial
- RAG Tutorial
- Machine Learning Tutorial
- Deep Learning Tutorial
- Ollama Tutorial
- Retrieval Augmented Generation (RAG) Tutorial
- Copilot Tutorial
- Gemini Tutorial
- ChatGPT Tutorial
No Comments