How to Draw Circle Using Turtle in Python - Simple Guide
To draw a circle using
turtle in Python, use the circle(radius) method of a turtle object. This method draws a circle with the specified radius on the screen.Syntax
The basic syntax to draw a circle with turtle is:
turtle.circle(radius): Draws a circle with the givenradius.- The
radiusis a number that sets the size of the circle. - Positive radius draws the circle counterclockwise; negative radius draws clockwise.
python
import turtle t = turtle.Turtle() t.circle(50) turtle.done()
Output
A window opens showing a circle with radius 50 drawn by the turtle.
Example
This example creates a turtle and draws a circle with radius 100 pixels. It shows how simple it is to use the circle() method.
python
import turtle screen = turtle.Screen() t = turtle.Turtle() t.circle(100) screen.mainloop()
Output
A window opens displaying a circle with radius 100 drawn by the turtle.
Common Pitfalls
Common mistakes when drawing circles with turtle include:
- Not calling
turtle.done()orscreen.mainloop()to keep the window open. - Using a negative radius without understanding it draws the circle clockwise.
- Forgetting to import the turtle module or create a turtle object.
python
import turtle t = turtle.Turtle() # Wrong: forgetting to keep window open # t.circle(50) # Right way: t.circle(50) turtle.done()
Output
A window opens showing a circle with radius 50 drawn by the turtle.
Quick Reference
Here is a quick summary of the circle() method parameters:
| Parameter | Description |
|---|---|
| radius | Radius of the circle (positive for counterclockwise, negative for clockwise) |
| extent (optional) | Portion of the circle to draw in degrees (default is 360 for full circle) |
| steps (optional) | Number of steps to approximate the circle (higher means smoother) |
Key Takeaways
Use the turtle object's circle(radius) method to draw circles easily.
Always call turtle.done() or screen.mainloop() to keep the drawing window open.
Positive radius draws counterclockwise circles; negative radius draws clockwise.
You can control how much of the circle to draw with the optional extent parameter.
The steps parameter controls the smoothness of the circle shape.