试用博客园编辑器

试用博客园编辑器试用博客园编辑器
1 # guess LuckyNum
 2 # 练习使用if_else语句
 3 # 使用循环语句while
 4 # 与、或、非 and、or、not
 5 
 6 MyLuckNum = 66
 7 NumInput = 0
 8 GuessCount = 5
 9 # while True:
10 while MyLuckNum != NumInput and GuessCount != 0:
11     NumInput = int(input("Please input number (0~100):"))
12     GuessCount -= 1
13     print("GuessCount=", GuessCount)
14 
15     if NumInput <= 100:
16         if NumInput > MyLuckNum:
17             print("the real num is smaller")
18         elif NumInput < MyLuckNum:
19             print("the real num is bigger")
20     else:
21         print("Input Error!")
22 if GuessCount == 0 and MyLuckNum != NumInput:
23     print("time is over!")
24 else:
25     print("bingo!")
GusessNumProgram

尝试

使用安科网自带编辑器上传文章2018-01-2315:51:15


哈哈

安科网

试用博客园编辑器

相关推荐