zoukankan      html  css  js  c++  java
  • python猜数字小游戏

    print("---------guess number--------")
    temp = input("please input you number :")
    guess = int(temp)
    num = 1
    number = int(num)
    while (guess !=8) and (number != 3):
         temp = input("erro,please input you number :")
       if guess == 8: print("ok") else: if guess > 8: print("litter big") number = number + 1 else: if guess < 8: print("a litter") number = number + 1 print("game over!")

     续(随机生成数字匹配)

    import random
    secret = random.randint(1,10)
    print("---------guess number--------")
    #temp = input("please input you number :")
    guess = secret
    #num = 1
    #number = int(num)
    while guess !=8:
    #     temp = input("erro,please input you number :")
         guess = random.randint(1,10)
         if guess == 8:
             print("ok,the number is :")
             print(guess)
             break
         else:
             if guess > 8:
                 print("litter big")
    #             number = number + 1
             else:
                 if guess < 8:
                     print("a litter")
    #                 number = number + 1
    print("game over!")
  • 相关阅读:
    【每天一道PAT】1001 A+B Format
    C++ STL总结
    开篇
    happen-before原则
    java多线程的状态转换以及基本操作
    集合初始容量
    fail-fast机制
    Stack
    Iterator
    Vector
  • 原文地址:https://www.cnblogs.com/changbo/p/5449544.html
Copyright © 2011-2022 走看看