Python-使用turtle模块绘制同心圆

使用画图模块turtle绘制同心圆

import turtle

t = turtle.Pen()
#获得画笔

my_color=("red","green","yellow","black")
t.width(
4) #画笔宽度
t.speed(0.2) #画笔画的速度
for i in range(10): #0,1,2,3,4
   
t.penup() #抬起笔
   
t.goto(0,-i*10)
    t.pendown()
#放画笔
   
t.color(my_color[i%len(my_color)]) # 对my_color的数量取余数
   
t.circle(10+i*10)#半径100

#t.goto(0,-100)#画笔向下移动100
#t.circle(200)
#t.goto(0,-200)
#t.circle(300)

turtle.done()  #程序执行完,窗口仍然在

 

你可能感兴趣的:(Python)