• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • Ruby
  • About
You are here: Home / Python / Draw Circle in Python Using turtle circle() Function

Draw Circle in Python Using turtle circle() Function

February 22, 2022 Leave a Comment

To draw a circle in Python, we can use the circle() function from the Python turtle module.

import turtle

t = turtle.Turtle()

def draw_circle(radius):
    t.circle(radius)

draw_circle(100)

The turtle module in Python allows us to create graphics easily in our Python code.

We can use the turtle module to make all sorts of shapes in Python. For example, we can draw rectangles and draw triangles easily in Python with the turtle module.

One other shape which is easy to draw with turtle is a circle.

The defining feature of a circle is the radius. To draw a circle in Python, we can use the turtle circle() function from the turtle module.

We can define a simple function which will take one argument, the radius of our circle, and make the circle.

Below is a simple example of how to use Python to create a circle.

import turtle

t = turtle.Turtle()

def draw_circle(radius):
    t.circle(radius)

draw_circle(100)

turtle circle

Cool Patterns You Can Make With circle() in Python

There are a few cool patterns you can create with the Python turtle circle() function.

One example is a spiral.

Below is the Python code for creating a spiral, and the output of the spiral with the turtle module.

import turtle
    
t = turtle.Turtle()
  
def draw_spiral(starting_radius, loops):
    for i in range(0, loops):
        t.circle(starting_radius + i, 60)      

draw_spiral(10, 100)

turtle spiral

You can also make concentric circles easily with the circle() function. To make concentric circles, we make circles starting in the middle, and keep increasing the radius until the end.

Below is the Python code for creating concentric circles.

import turtle
    
t = turtle.Turtle()
  
def draw_concentric_circles(starting_radius, loops):
    for i in range(0, loops):
        t.circle(starting_radius*i)  
        t.up()
        t.sety((starting_radius *i)*(-1))
        t.down()    

draw_concentric_circles(10, 25)

turtle concentric circles

How to Draw a Circle with Different Colors in Python

With turtle, we can easily add color to the shapes we create.

The main function you can use to change the color of a line is with the turtle pencolor() function.

Below is an example and the output of how to draw a green circle using pencolor() in Python.

import turtle

t = turtle.Turtle()

t.pencolor("green")

t.circle(50)

turtle color green circle

To fill a shape, there are a few steps to take. We use the fillcolor() function to define the fill color of our shape, and then use the begin_fill() and end_fill() functions to define when to begin and end filling shapes with the fill color.

Below is an example and the output of how to fill a circle with the color ‘blue’ using fillcolor(), begin_fill() and end_fill() in Python.

import turtle

t = turtle.Turtle()

t.fillcolor("blue")

t.begin_fill()

t.circle(50)

t.end_fill()

turtle fill color blue circle

Hopefully this article has been helpful for you to learn how to draw a circle in Python.

Other Articles You'll Also Like:

  • 1.  How to Group and Aggregate By Multiple Columns in Pandas
  • 2.  How to Check if String Contains Uppercase Letters in Python
  • 3.  Python turtle write() – Write Text to Turtle Screen
  • 4.  Python Prime Factorization – Find Prime Factors of Number
  • 5.  Python Turtle Fonts – How to Write Text with Different Fonts in Python
  • 6.  Using Python to Check if Number is Divisible by Another Number
  • 7.  Set Widths of Columns in Word Document Table with python-docx
  • 8.  Multiple Condition if Statements in Python
  • 9.  Symmetric Difference of Two Sets in Python
  • 10.  How to Split List in Half Using Python

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About The Programming Expert

the programming expert main image

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2023 · The Programming Expert · About · Privacy Policy

x