Commit 0892cd6f by BellCodeEditor

save project

parent 576b5884
Showing with 34 additions and 0 deletions
import turtle
import random
color=['snow','lightcoral']
def tree(n):
if n>=0:
angle=random.randint(1,20)
length=random.randint(1,10)
if n <=12:
pen.color(color[random.randint(0,1)])
pen.pensize(n/3)
else:
pen.color('sienna')
pen.pensize(n/10)
pen.forward(n)
pen.right(angle)
tree(n-length)
pen.left(2*angle)
tree(n-length)
pen.right(angle)
pen.up()
pen.backward(n)
pen.down()
pen = turtle.Turtle()
pen.color('sienna')
w = turtle.Screen()
w.bgcolor('wheat')
pen.speed(100)
pen.left(90)
pen.up()
pen.backward(150)
pen.down()
tree(50)
turtle.done()
\ No newline at end of file
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