banner



How To Draw A Circle In Python Without Turtle

Part-2: Turtle in Python.

Sawan Rai

Don't worry… it's not slow.

Photo by Patti Black on Unsplash

In the previous part we have covered basic drawings in Turtle. In this post we will take forward our dicsussion. If you haven't read the previous part, please visit the following link:

Circle: We can draw a circle of radius n with the help of cricle(n) method of Turtle class.

Multiple Circle: Here, we are making several circles with the same focal point and continuously increasing radius. We can pass random colors into the pencolor method in (R,G,B) format. We use random function to assign values to R,G and B. We used penup() and pendown() method here. Before moving the pointer to a particluar location we call the penup() method. After reaching to the location we call pendown() method. In this way, pointer will not draw a line while moving.

Multiple Circle 2: Here, we are making several circles with the varing focal point and continuously increasing radius.

Cone: Here, we will use the circle to draw a cone type shape in each quadrant of the X-Y plane. In side the while loop, we have four for loops (one for each quadrant). In each for loop we draw multiple circles with monotonically increasing radius and the focal point. We also assign random colors to these circles.

Square: Now we will draw an square with the help of lines. We have right() and left() methods in the Turtle class, which move the face of the pointer to right or left with the specified angle. First, we take 90 degree right and move 100 points in the forward direction. Next, we again take 90 degree right and move forward and so on…… Your can dry run and trace the ouput for the better understanding. In the same way, you can make different polygons with different values of angle and length.

Multiple squares: In this drawing we are creating multiple squares of different length and colors. rt and fd are the shortforms for right() and forward() methods.

Final Show: This is the final example of our post. Here, we make stars at random locations on the screen. At the same time, we change the background color of the screen also. If you have followed the previous examples, you can easily understand this one.

If you are reading this line…. then Congrats . You have completed a short tour on Turtle. Now play with the examples, and create more attractive and complex drawings. This library can help in improving the logic building with visualization. You will not feel irritated and always find something interesting on the output. You can get the code files and the outputs in the following Github repository: https://github.com/sawan16/turtle_data

For more details go through the following link. I have taken few data from the same link also. Thank you for reading… Enjoy learning….

How To Draw A Circle In Python Without Turtle

Source: https://medium.com/analytics-vidhya/part-2-turtle-in-python-8708e2ba68f5

Posted by: stewartquidents53.blogspot.com

0 Response to "How To Draw A Circle In Python Without Turtle"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel