import turtle
from random import *
from math import *

turtle.seth(90)
def tree(n,l):
    turtle.down()
    turtle.pencolor('#410200')
    turtle.pensize(n*3)
    turtle.forward(l)

    if n>0:
        turtle.right(30)#向右偏移
        tree(n-1,l*0.7)
        turtle.left(60)#向左偏移
        tree(n-1,l*0.6)
        turtle.right(30)
    else:
        #画叶子
        turtle.dot(10,'green')
    turtle.up()
    turtle.backward(l)#返回
tree(3,200)

效果:

  

 

 

import turtle
import random

a=turtle.pos()
n=36
while n>0:
    n=n-1
    turtle.right(n*10)
    turtle.up()
    turtle.forward(20)
    turtle.down()
    turtle.dot(10,'green')
    turtle.left(n*10)
turtle.up()
turtle.goto(a)

 

posted on 2021-06-08 13:41  慢乌龟  阅读(68)  评论(0编辑  收藏  举报