zoukankan      html  css  js  c++  java
  • 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
     
  • 相关阅读:
    Centos7.3安装jdk和maven
    Centos7.3安装sftp服务和ssh
    Centos7.3安装,并设置网络和防火墙
    Docker 常用命令
    Tomcat配置
    MySQL配置
    配置JDK
    JTable的模型
    JavaBean和List<JavaBean>
    JavaBean
  • 原文地址:https://www.cnblogs.com/weifeng1463/p/7515784.html
Copyright © 2011-2022 走看看