📜  2. 写一个程序来画这个.假设最里面的正方形每边有 20 个单位,每个连续的正方形每边比里面的那个大 20 个单位. - 打字稿代码示例

📅  最后修改于: 2022-03-11 14:48:30.356000             🧑  作者: Mango

代码示例1
import turtle
wn = turtle.Screen()
wn.bgcolor("lightgreen")
tess = turtle.Turtle()

def draw_square(t,size):
    for i in range(4):
        tess.forward(size)
        tess.left(90)

size = 20
for j in range(3):
   tess.pensize(3)
   draw_square(tess,size)
   size = size + 20
   tess.penup()
   tess.goto(-20, -20)
   tess.pendown()

wn.mainloop()