赞
踩
废话不多说,上代码:
- import random
- life=5
- ans=0
- print("欢迎来到猜数字游戏!")
- print('1.1~15')
- print('2.1~30')
- print('3.1~100')
- NUMBER=int(input('请选择您的等级:'))
- if NUMBER==1:
- guess=random.randint(1,15)
- a=True
- while a:
- number=int(input('Type a number:'))
- if number>guess:
- print("Too Big!")
- life-=1
- print('Life is ',life)
- ans+=1
- elif number<guess:
- print("Too Small!")
- life-=1
- print('Life is ', life)
- ans += 1
- else:
- print("That's Right!")
- ans+=1
- print('你用了', ans, '次')
- a=False
- if life==0:
- print("The number is",guess)
- a=False
- if NUMBER==2:
- guess = random.randint(1,30)
- a = True
- while a:
- number = int(input('Type a number:'))
- if number > guess:
- print("Too Big!")
- life -= 1
- print('Life is ', life)
- ans += 1
- elif number < guess:
- print("Too Small!")
- life -= 1
- print('Life is ', life)
- ans += 1
- else:
- print("That's Right!")
- ans += 1
- print('你用了', ans, '次')
- a = False
- if life == 0:
- print("The number is", guess)
- a = False
- if NUMBER==3:
- guess = random.randint(1,100)
- a = True
- while a:
- number = int(input('Type a number:'))
- if number > guess:
- print("Too Big!")
- life -= 1
- print('Life is ', life)
- ans += 1
- elif number < guess:
- print("Too Small!")
- life -= 1
- print('Life is ', life)
- ans += 1
- else:
- print("That's Right!")
- ans += 1
- print('你用了', ans, '次')
- a = False
- if life == 0:
- print("The number is", guess)
- a = False
- if NUMBER!=1 and NUMBER!=2 and NUMBER!=3:
- print('输入错误!程序崩溃!')
- print('Windows崩溃!')
- a=False
emmm没有注释哟~~~~
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。