Learn Python: Drawing Circles

No one can draw a standard circle without the help of tools, and a standard circle can be drawn quickly with a program.

Enter the following code:

import turtle as t

import time

b=t.Pen()

for x in range(1,2):

b.circle(50)

b.circle(-50)

b.forward(100)

b.circle(50)

b.circle(-50)

time.sleep(5)

We can get the 4 circles in the picture below.

image

Use the following code to draw concentric circles

import turtle as t

import time

b=t.Pen()

for x in range(10,60,6):

b.circle(x)

b.penup() #提起笔就可以不绘制

b.right(90)

b.forward(5)

b.right(270)

b.pendown()#放下笔,准备绘制

time.sleep(5)

image

If you want to draw an arc, you can use the following code

import turtle as t

import time

b=t.Pen()

for x in range(10,90,6):

b.circle(x,90+x*2)

b.penup()

b.home() #回到起点

b.pendown()

time.sleep(5)

image

——————————————
How to receive python welfare tutorial:
1. Like + comment (check "Retweet at the same time")
2. Follow the editor. And private message reply keyword [19]
(be sure to private message ~ click on my avatar to see the private message button)

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326819843&siteId=291194637