标签:返回 size lse div nbsp import dom pen while
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)
标签:返回 size lse div nbsp import dom pen while
原文地址:https://www.cnblogs.com/mwg666/p/14144239.html