Commit ac9b9d4f by BellCodeEditor

save project

parent 683b6808
Showing with 19 additions and 16 deletions
import turtle
import random
pen = turtle.Turtle()
pen.color('sienna')
# 画布大小
w = turtle.Screen()
w.bgcolor('wheat') # wheat小麦
pen.speed(100000000000)
# 移动到起点
pen.left(90)
pen.up()
pen.backward(150) # 后退
pen.down()
pen.forward(100)
pen.right(30)
pen.forward(50)
pen.penup()
pen.forward(-50)
pen.pendown()
pen.left(60)
pen.forward(50)
pen.penup()
pen.forward(-50)
pen.right(30)
pen.forward(-100)
pen.setheading(90)
def tree(n):
if n>=10:
long=random.randint(5,15)
jiao=random.randint(5,50)
pen.forward(n)
pen.right(jiao)
tree(n-long)
pen.left(jiao*2)
tree(n-long)
pen.right(jiao)
pen.penup()
pen.forward(-n)
pen.pendown()
tree(100)
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