Commit ef5b2b4e by BellCodeEditor

save project

parent 576b5884
Showing with 34 additions and 0 deletions
import turtle
import random
pen = turtle.Turtle()
pen.color('sienna')
w = turtle.Screen()
w.bgcolor('wheat') # wheat小麦
pen.left(90)
pen.up()
pen.backward(150) # 后退
pen.down()
pen.speed(0)
def tree(l):
if l>=0:
pen.pensize(l/10)
if l<12:
color_list=["snow","lightcoral","red"]
color=random.choice(color_list)
pen.pensize(l/3)
pen.color(color)
else:
pen.pensize(l/10)
pen.color("sienna")
a=random.randint(5,30)
b=random.randint(5,15)
pen.forward(l)
pen.right(a)
tree(l-b)
pen.left(a*2)
tree(l-b)
pen.right(a)
pen.color("sienna")
pen.backward(l)
tree(75)
turtle.done()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment