Draw Circle In Python Without Turtle
In this tutorial we will see how to draw a circle in python without turtle, I will show you how to create this program so follow this tutorial till the end.
To draw circle in python I will use the pygame library which is mainly used for game development in python but we will draw circle in pygame.
Code To Draw Circle In Python Without Using Turtle
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 python code to draw a circle in python using pygame. 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
After installing you can run the program and you will see a new window opened and a circle drawn like below.
Want to know how to draw square in python without using turtle refer here: Draw a square in python without turtle library.
This was the simple tutorial to draw a circle in python without using turtle library. I hope you found this tutorial helpful and useful. Do share it with your friends who might be interested in this program.
Thanks for reading, Have a nice day 🙂