Coders Packet

python program to draw a circle of squares using Turtle

By Karthik Nagisetty

  • turtle using python - Shortcut.lnk
  • 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)
    

     

     

     

    Download Complete Code

    Comments

    No comments yet

    Download Packet

    Reviews Report

    Submitted by Karthik Nagisetty (karthik)

    Download packets of source code on Coders Packet