Circle of Squares using Python
Turtle library enables users to draw pictures or shapes using commands, providing them with a virtual canvas. turtle comes with Python’s Standard Library. It needs a version of Python with Tk support, as it uses tkinter for the graphics. In this article, 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 as to complete a full circle. In the implementation below we will draw a circle of 60 squares, rotating the cursor each time by 6 degrees.
- fd(x) : draw the cursor forward by x pixels.
- rt(x) : rotates the facing direction of the cursor by x degrees to the right.
Below is the implementation.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course