python program to draw a circle of squares using Turtle

Karthik Nagisetty Jul 11, 2023

In this program, we will generate a circular pattern out of squares using python's turtle module.

python program to draw a circle of squares using Turtle

In this program,we will generate a circular pattern out of squares using python's Turtle module.

For drawing the circle,we need to draw n number of square,each time rotating the turtle cursor by d degrees. n and d are chosen such that,

n*d=360.

so by this way we can complete a full circle.

 

Now to draw a circle using turtle, we will use a predefined function in "turtle".circle(radius):This function draws a circle of the given radius by taking the 

This funtion always draws a circle of the given radius by taking the "turtle" position as the cente

import turtle 
x=turtle.Turtle()


def square(angle):
x.forward(100)
x.right(angle)
x.forward(100)
x.right(angle)
x.forward(100)
x.right(angle)
x.forward(100)
x.right(angle+10)

for i in range(36):
square(90)

 

 

 

Project Files

Loading...
..
This directory is empty.

Comments (0)

Leave a Comment