首页 > 代码库 > python 初学--第一个猜数字小游戏
python 初学--第一个猜数字小游戏
import randomnum = random.randint(0,100)print numtimes = 0print "Number[0,100] guess game"print "You will have 10 times to guess"print "Guess out of range will game over immediately!"guess = int(raw_input("guess a number:"))times = times + 1while times < 10: if guess<0 or guess>100: print "Your guess is out of range!Game over!" breakelse: if guess > num: print "Too high,guess again!" elif guess < num: print "Too Low,guess again!" else: print "You guess it.The number is:",num score = 10*(11-times) print "times is:",times print "Your score is",score break guess = int(raw_input("guess a number:")) times = times + 1else: if guess > num: print "Too high,The number is:!",num print "Guess times over,game over!" elif guess < num: print "Too Low,The number is:!",num print "Guess times over,game over!" else: print "You guess it.The number is:",num score = 10*(11-times) print "times is:",times print "Your score is",score
python 初学--第一个猜数字小游戏
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。