• python学习:猜数字游戏


    猜数字游戏
     
    系统生成一个100以内的随机整数,
    玩家有6次机会进行猜猜看,每次猜测都有反馈(猜大了,猜小了,猜对了-结束)
    6次中,猜对了,玩家赢了。
    否则系统赢了
     
    #!/usr/bin/env python
    import random
    secret=random.randint(1,100)
    guess=0
    tries=0
    print "This game is to guess a number for you!"
    print " It is a number from 1 to 99,I'll give you 6 times to try. "
    while guess != secret and tries < 6:
        guess=input("Please input your guess number: ")
        if guess < secret:
            print "====Your guess is too low !==== "
     
     
        elif guess > secret:
            print "====Your guess is too high!==== "
        tries=tries+1
    if guess == secret:
            print "Congratulations to you! Your  guess is right ! "
    else:
            print "No more guesses! Good luck next time for you!"
            print "The secret number was",secret
     
  • 相关阅读:
    单页面应用 之 项目中集成插件vue-router
    公共组件的创建和使用
    数据库初识
    MySQL的安装 --windows版本
    多线程补充以及协程
    多线程(三)
    多线程(二)
    多线程(一)
    多进程(二)
    多进程(一)
  • 原文地址:https://www.cnblogs.com/weifeng1463/p/7515784.html
Copyright © 2020-2023  润新知