Commit 2d9a134f by BellCodeEditor

save project

parent b2d26f5a
Showing with 15 additions and 25 deletions
class Hero: bingo_num = 20
def __init__(self,name,hp,attack): num_list = [1,3,5,8,11,15,17,18,20,21]
self.level = 1
self.name = name low = 0
self.hp = hp high = len(num_list)-1
self.attack = while low <= high:
mid = (low + high) // 2
def ypgrade(): guess = num_list[mid]
yase.level=yase.level+1 if guess == bingo_num:
yase.hp=yase.hp+50 print("找到了,它的索引是:",mid)
yase.attack=yase.attack+4 break
elif guess < bingo_num:
yase = Hero("亚瑟",300,20) low = mid + 1
print("亚瑟的血量为: ",yase.hp) else:
upgrade() high = mid - 1
upgrade()
print("升级2次后,亚瑟的血量为: ",yase.hp)
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