玩蛇网提供最新Python编程技术信息以及Python资源下载!
您现在的位置: 玩蛇网首页 > Python源码实例 > 游戏开发代码 > 正文内容

一个简单的猜字游戏python代码

import random

print('**********Guess Number game********')
#www.iplaypy.com
result = random.randint(1,10)
print('result is '+str(result))

while True:
    guess = int(input('Guess Number'))

    if guess < result:
        print('Numbe is low')
        continue

    elif guess > result:
        print('Numbe is high')
        continue

    elif guess > 20 or guess <1:
        print('Numbe is out of range')
        continue

    elif guess == result:
        print('yes you are right!')
        break

    else:
        print('please !!')

玩蛇网文章,转载请注明出处和文章网址:http://www.iplaypy.com/code/game/g2481.html

相关文章 Recommend

玩蛇网Python互助QQ群,欢迎加入-->: 106381465 玩蛇网Python新手群
修订日期:2016年03月31日 - 08时28分50秒 发布自玩蛇网

我要分享到:

必知PYTHON教程 Must Know PYTHON Tutorials

必知PYTHON模块 Must Know PYTHON Modules