Commit ceab9b57 by BellCodeEditor

save project

parent 78a3ec3c
Showing with 86 additions and 14 deletions
import turtle as t
import time
t.speed(100)
t.bgcolor("black")
t.pencolor("blue")
t.pensize(2)
t.hideturtle()
t.tracer(0)
while True:
for i in range(30):
for o in range(6):
t.fd(150)
t.right(60)
t.right(12)
t.update()
t.clear()
time.sleep(0.02)
\ No newline at end of file
# 和你的小伙伴用列表讲讲桃园结义的故事,并说说这其中运用了哪些列表知识: import turtle
# 来,我给你起个头~ import random
# 从前啊,有三个bro,分别是:刘备、关羽、张飞... from turtle import *
bro1="关羽" from time import sleep
bro2="刘备" #画樱花的躯干
bro3="张飞" def tree(branchLen,t):#branchlen树脂长度,T表示turtle对象
bros=["刘备","关羽","张飞"] sleep(0.0005)
bro1=["关羽",160,8.5] if branchLen >3 :
bro2=["刘备",161,9.1] if 8 <=branchLen <=12:
bro3=["张飞",166,8.3] if random.randint(0,2)==0:
bros[0]="关羽" t.color("snow") #白
bros[1]="刘备" else:
print(bros) t.color("lightcoral")#淡三湖色
\ No newline at end of file t.pensize(branchLen/3)
elif branchLen<8:
if random.randint(0.001)==0:
t.color("snow")
else:
t.color("lightcoral")
t.pensize(branchLen/2)
else:
t.color("sienna")#樍色
t.pensize(branchLen/10)
t.forward(branchLen)
a=1.5*random.random()
t.right(20*b)
b=1.5*random.random()
tree(branchLen-10*a,t)
t.left(40*a)
tree(branchLen-10*a,t)
t.right(20*b)
t.up()
t.backwark(branchLen)
t.down()
def petal(m,t):
for i in range(m):
a=200-400*random.random()
b=10-20*random.random()
t.up()
t.forward(a)
t.left(90)
t.forward(b)
t.down()
t.color("lightcoral")
t.circle(1)
t.up()
t.backward(a)
t.right(90)
t.forward(b)
def main():
t=turtle.Turtle()
w=turtle.Screen()
t.hideturtle()
getscreen().tracer(5,0)
w.screensize(bg='wheat')
t.left(90)
t.up()
t.backward(150)
t.down()
t.color("sienna")
tree(60,t)
petal(200,t)
w.exitonclick()
main()
t.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