python经典程序练习题12:绘制正方形螺旋线

绘制下图的正方形螺旋线:

源代码:

import turtle as t
t.pen(speed=0)   #加快绘图速度
t.penup()
t.goto(-200, -200)     #以左下角某处为起点
t.pendown()
t.seth(0)
length = 400
while (length !=0):    #利用正方形螺旋线的性质来绘图
    t.fd(length)
    t.left(90)
    length -= 2.5
t.hideturtle()         #绘图结束后把海龟头(笔触头)隐藏起来
t.done()               #绘图结束后使窗口停留

猜你喜欢

转载自blog.csdn.net/qq_41149269/article/details/81096473
今日推荐