Commit d4117e3a by BellCodeEditor

save project

parent 704637a7
Showing with 13 additions and 36 deletions
import turtle
import random
num_list=[1,3,5,8,11,15,17,18,20,21]
num=20
low=0
high=len(num_list)-1
while low<=high:
mid=(low+high)//2
guss=num_list[mid]
if guss==num:
print("找到了")
elif:guss<num:
low=mid+1
else:
high=mid-1
pen = turtle.Turtle()
pen.color('sienna') #画笔颜色
# 画布大小
w = turtle.Screen()
w.bgcolor('wheat') # wheat小麦画布颜色
# 移动到起点
def tree(n):
if n>=0:
if n<=12:
color_list=['snow','lightcoral']
color=random.choice(color_list)
pen.color('siema')
pen.pensize(n/3)
else:
pen.color('sienna')
pen.pensize(n/10)
pen.forward(n)
al = random.random()
pen.right(30*al)
le =15*random.random()
tree(n-le)
pen.left(60*al)
tree(n-le)
pen.right(30*al)
pen.up()
pen.backward(n)
pen.down()
pen.left(90)
pen.up()
pen.backward(150) # 后退
pen.down()
tree(50)
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