ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
``` import turtle def tree(n,l): turtle.pen(fillcolor="black", pencolor="red", pensize=10) turtle.forward(225) print(sorted(turtle.pen().items())) print('------------') print(turtle.pen().items()) tree(12,100) tree(5,'5') ``` ``` from turtle import * from random import * from math import * def tree(n,l): pd()#下笔 #阴影效果 t = cos(radians(heading()+45))/8+0.25 pencolor(t,t,t) pensize(n/3) forward(l)#画树枝 if n>0: b = random()*15+10 #右分支偏转角度 c = random()*15+10 #左分支偏转角度 d = l*(random()*0.25+0.7) #下一个分支的长度 #右转一定角度,画右分支 right(b) tree(n-1,d) #左转一定角度,画左分支 left(b+c) tree(n-1,d) #转回来 right(c) tree(5,50) ```