|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
刚学python几天的时候,看到小甲鱼写的猜字游戏。我就想到了酒桌上玩得那种猜字游戏。1到100以内,题主在心里选个数,然后其他的小伙伴猜数。比如,题主选50,我猜70,然后题主会说,0到70;我猜35,题主会说,35到70.......直到猜中。下面是根据这个写的小程序的代码,我菜鸟一个,让各位笑话了。有啥改进意见,请不要吝啬,第一次发帖,请多海涵。(*^__^*) 嘻嘻……
- import random
- num = random.randint(0,101)
- MAX = 100
- MIN = 0
- while True:
- temp = input('Please guess the number:')
- INPUT = int(temp)
- if INPUT > num:
- MAX = INPUT
- print('The number is between ',MIN ,'-',MAX)
- if INPUT == num:
- print('You get the right number')
- break
- if INPUT < num:
- MIN = INPUT
- print("The number is between ",MIN,'-',MAX)
-
复制代码
|
-
程序运行截图
评分
-
查看全部评分
|