# 猜数字小游戏

import random

import sys

num=random.randint(1,20)

print "------------------------------------------------------------------------------"

print '''Game rules:

There is a integer between 1 and 20.If you can guess it in six chances,you win the game,otherwise you lose the game.Good Luck!'''

print "------------------------------------------------------------------------------"

for i in xrange(1,7):

j=int(raw_input("Please guess the integer(1-20): "))

if j > num:

print "Too big!!You Still have %s chance!"%(6-i)

elif j < num:

print "Too small!!You Still have %s chance!"%(6-i)

elif j == num:

print "You win!!!"

sys.exit()

else:

print "You have already guess 6 times,You Lose!!!"

Game rules:

There is a integer between 1 and 20.If you can guess it in six chances,you win the game,otherwise you lose the game.Good Luck!

------------------------------------------------------------------------------

Please guess the integer(1-20): 2

Too small!!You Still have 5 chance!

Please guess the integer(1-20): 10

Too small!!You Still have 4 chance!

Please guess the integer(1-20): 15

Too small!!You Still have 3 chance!

Please guess the integer(1-20): 19

Too big!!You Still have 2 chance!

Please guess the integer(1-20): 18

You win!!!

103 篇文章35 人订阅

0 条评论