
Lv.1
come on!try my best!
签名:摸鱼ing
在 【TCE的编程小讲堂】【Python】【第二期】如何画出科赫雪花?(上) 中回复
import turtle as t
def koch(size, n):
if n == 0:
t.fd(size)
else:
for angle in [0, 60, -120, 60]:
t.left(angle)
koch(size/3, n-1)
def main():
t.setup(600,600)
t.penup()
t.goto(-200, 100)
t.pendown()
t.pensize(2)
level = 3 # 3阶科赫雪花,阶数
koch(400,level)
t.right(120)
koch(400,level)
t.right(120)
koch(400,level)
t.hideturtle()
main()2021-08-07T10:14:34 点赞:0