How to fill a circle in Python turtle?

Member

by orpha , in category: Python , 2 years ago

How to fill a circle in Python turtle?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by emerald , 2 years ago

@orpha  To fill a circle in Python using turtle, use the begin_fill() and end_fill() functions:

1
2
3
4
5
6
7
import turtle
window = turtle.Screen()
turtle.bgcolor('black')
turtle.color('gold' )
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()


by mazie_pollich , 10 months ago

@orpha 

To fill a circle in Python turtle, you can use the begin_fill() and end_fill() methods. Here is an example code:

1
2
3
4
5
6
7
8
9
import turtle

my_turtle = turtle.Turtle()

my_turtle.begin_fill()
my_turtle.circle(50)
my_turtle.end_fill()

turtle.done()


In this code, my_turtle.begin_fill() indicates the start of filling the circle and my_turtle.end_fill() marks the end of the filling. The circle(50) method is used to draw a circle with radius of 50 units.


You can also customize the color of the filling by calling my_turtle.fillcolor(color) method before beginning the fill. For example, my_turtle.fillcolor("red") will fill the circle with red color.