Pythondex
Python Programs

Draw Circle In Python Without Turtle

Last updated June 21, 2023 by Jarvis Silva

In this tutorial we will see how to draw a circle in python without turtle, To draw circle we will use the pygame library which is mainly used for game development in python but we will draw a circle with it.

Python Code To Draw Circle


import pygame
import math

pygame.init()

# Set the size of the circle and the window
size = width, height = 400, 400
screen = pygame.display.set_mode(size)
screen_colr = 255, 255, 255
screen.fill(screen_colr)

# Set the position and radius of the circle
radius = 150

# Draw the circle
for i in range(0, 360, 1):
    x = 200 + int(radius * math.cos(math.radians(i)))
    y = 200 + int(radius * math.sin(math.radians(i)))
    pygame.draw.circle(screen, (0, 0, 0), (x, y), 1)

# Update the display
pygame.display.flip()

# Keep the window open until it is closed
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()


Above is the code for drawing a circle using pygame module, you can run this program on your computer or use this web online compiler.

Before running this program you need to install pygame in your system you can do it by using the below command.


pip install pygame

So when you run the program and you will see a new window opened and a circle drawn like below.

Circle Drawing In Python

I hope you found this tutorial helpful and useful, Do share it with your friends who might be interested in this program, Want to know how can you draw a square in python without using the turtle module then refer here: Draw a square in python without turtle library.

Thanks for reading, Have a nice day 🙂