Commit dc302000 by BellCodeEditor

save project

parent 025c7a27
Showing with 48 additions and 12 deletions
import turtle
bingo_num = 17
num_list = [1,3,5,8,11,15,17,18,20,21]
low = 0
high = len(num_list)-1
while low <= high:
mid = (low + high) //2
guess = num_list[mid]
if guess == bingo_num:
print("找到了,他的索引是:",mid)
break
elif guess < bingo_num:
low = mid + 1
else:
high = mid - 1
pen = turtle.Turtle()
pen.color('sienna')
w = turtle.Screen()
w.bgcolor('wheat') # wheat小麦
# 移动到起点
pen.left(90)
pen.up()
pen.backward(150) # 后退
pen.down()
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