# guess LuckyNum
# 练习使用if_else语句
# 使用循环语句while
# 与、或、非 and、or、not
MyLuckNum = 66
NumInput = 0
GuessCount = 5
# while True:
while MyLuckNum != NumInput and GuessCount != 0:
NumInput = int(input("Please input number (0~100):"))
GuessCount -= 1
print("GuessCount=", GuessCount)
if NumInput <= 100:
if NumInput > MyLuckNum:
print("the real num is smaller")
elif NumInput < MyLuckNum:
print("the real num is bigger")
else:
print("Input Error!")
if GuessCount == 0 and MyLuckNum != NumInput:
print("time is over!")
else:
print("bingo!")
编码