Commit 501214be by BellCodeEditor

save project

parent bae41ef6
Showing with 74 additions and 0 deletions
bingo_num=20
num_list=[1,3,5,8,11,15,17,18,20,21]
l=0
h=len(num_list)
while l<=h:
m=(l+h)//2
guess_num=num_list[m]
if guess_num==bingo_num:
print("找到了,他在列表中的索引是",m)
break
elif guess_num<bingo_num:
l=m+1
elif guess_num>bingo_num:
h=m-1
\ No newline at end of file
import turtle
import random
def tree(n):
if n >= 0:
pen.pensize(n/10)
angle = random.randint(0,30)
length = random.randint(1,15)
if n-length <= 12:
pen.color("snow" or "lightcoral")
pen.pensize(n/3)
else:
pen.color("sienna")
pen.pensize(n/10)
pen.forward(n)
pen.right(angle)
pen.down()
tree(n-length)
pen.up()
pen.left(2*angle)
pen.down()
tree(n-length)
pen.up()
pen.right(angle)
pen.backward(n)
pen = turtle.Turtle()
pen.speed(0)
pen.color('sienna')
# 画布大小
w = turtle.Screen()
w.bgcolor('wheat') # wheat小麦
# 移动到起点
pen.left(90)
pen.up()
pen.backward(150) # 后退
pen.down()
# pen.forward(100)
# pen.right(30)
# pen.forward(50)
# pen.up()
# pen.backward(50)
# pen.down()
# pen.left(60)
# pen.forward(50)
# pen.up()
# pen.backward(50)
# pen.right(30)
# pen.backward(100)
tree(60)
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