0
点赞
收藏
分享

微信扫一扫

Python中使用turtle绘制多个同心圆

微言记 2023-03-12 阅读 86


效果

Python中使用turtle绘制多个同心圆_python

代码

import turtle
t = turtle.Pen()
my_colors = ("red","green","yellow","black")
t.width(4)
t.speed(1)
for i in range(10): #0 1 2 3 4
t.penup()
t.goto(0,-i*10) #0, -100,-200,-300,-400
t.pendown()
t.color(my_colors[i%len(my_colors)])
t.circle(15+i*10) #100,200,300, 400,, 500
turtle.done() #程序执行完,窗口仍然在

 

举报

相关推荐

0 条评论