1. 【操作】绘制多个同心圆

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()  # 程序执行完,窗口仍然在

执行结果:

彩色同心圆python 彩色同心圆程序设计_彩色同心圆python

2. 【操作】绘制 18*18 棋盘

# 画棋盘
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)

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()  # 保证运行窗口不被自动关闭

输出结果:

 

彩色同心圆python 彩色同心圆程序设计_ci_02