绘制同心圆
import turtle
t = turtle.Pen()
t.width(4)
my_color = ("red","yellow","blue","green")
for i in range(5):
t.penup()
t.goto(0,-i*20)
t.pendown()
t.color(my_color[i % len(my_color)])
t.circle(30+i*20)
turtle.done()
绘制棋盘
import turtle
width = 30
num = 18
x1 = [(-400,400),(-400+width*num,400)]
y1 = [(-400,400),(-400,400-width*num)]
t = turtle.Pen()
t.speed(10)
# t.goto(x1[0][0],x1[0][1])
# t.goto(x1[1][0],x1[1][1])
for i in range(0,19):
t.penup()
t.goto(x1[0][0],x1[0][1]-30*i)
t.pendown()
t.goto(x1[1][0],x1[1][1]-30*i)
for i in range(0,19):
t.penup()
t.goto(y1[0][0]+30*i,y1[0][1])
t.pendown()
t.goto(y1[1][0]+30*i,y1[1][1])
t.hideturtle() #隐藏画笔
turtle.done() #保证运行窗口不被自动关闭