中国大学 MOOC 课程 《Python 语言程序设计》第五周绘制树
# drawtree.py
from turtle import Turtle, mainloop
def tree(plist, l, a, f):
""" plist is list of pens
l is length of branch
a is half of the angle between 2 branches
f is factor by which branch is shortened
from level to level."""
if l>5: #与之前的基例不同,这次递归,采用l长度与5的比较来结束递归。
lst = []
for p in plist:
p.forward(l)#沿着当前的方向画画Move the turtle forward

最低0.47元/天 解锁文章
4314

被折叠的 条评论
为什么被折叠?



