递归画树

2+
import turtle
def draw_tree(d,n):
if n > 0 :
turtle.fd(d)
turtle.dot(10,'magenta')
turtle.rt(25)
draw_tree(d-6,n-1)
turtle.lt(50)
draw_tree(d-6,n-1)
turtle.rt(25)
turtle.bk(d)
turtle.speed(0)
turtle.bgcolor('black')
turtle.color('cyan')
turtle.shape('turtle')
turtle.shapesize(2)
turtle.setheading(90)
turtle.left(25)
draw_tree(60,8)
turtle.rt(50)
draw_tree(60,8)
turtle.lt(25)
turtle.bk(100)

2+

发表评论