zoukankan      html  css  js  c++  java
  • Python练习-猜年龄的LowB游戏

    Alex大神今天让我做一个猜年龄的游戏:

    第一个游戏是你只能猜三次:真的很LowB啊~

    # 编辑者:闫龙
    #猜年龄游戏,3次后程序自动退出!
    ages = 29;
    #for循环3次
    for i in range(3):
        #输入年龄
        age = input("请输入你猜想的年龄:");
        try:
            age = int(age);
        except:
            print("你输入的‘"+age+"’是什么鬼!");
            break;
        if  age == ages :
            print("猜对了!666");
        elif age > ages:
            print("其实我比你想象的要年轻一些");
        elif age < ages:
            print("谢谢,但是我没你想你的那么稚嫩");
        if i >= 2:
            print("你尝试太多次了,游戏结束!")
            break;

    第二个游戏是你猜三次之后,提示你是否继续:真的太LowB了啊~

    # 编辑者:闫龙
    #猜年龄游戏,每三次提示一次是否继续!
    age = 28;
    i = 0;
    while True:
        i+=1;
        if i == 4:
            YesOrNo=input("请问您是否要继续(y/n)");
            if YesOrNo == "n" or YesOrNo == "No" or YesOrNo == "N" or YesOrNo =="no" :
                print("客官~欢迎下次再来玩儿哟~");
                break;
            elif YesOrNo == "y" or YesOrNo == "yes" or YesOrNo == "Y" or YesOrNo =="Yes" :
                i = 1;
            else :
                print("你看不懂人话吗?你输入的是什么鬼?");
                i-=1;
                continue;
        ages = input("请输入你猜的年龄:");
        try:
            ages = int(ages);
        except:
            print("你输入的‘"+ages+"’是什么鬼!");
            break;
        if age == ages:
            print("Congratulations 你猜对了!");
            print("你知道的太多了!~~~~~Game Over!");
            break;
        elif age > ages:
            print("谢谢,我没你想的那么年轻");
        elif age< ages:
            print("我看起来真的那么老吗?");

    说实话,我特么真心不想加注释,太LowB了!

  • 相关阅读:
    边工作边刷题:70天一遍leetcode: day 52
    边工作边刷题:70天一遍leetcode: day 53-1
    边工作边刷题:70天一遍leetcode: day 53
    边工作边刷题:70天一遍leetcode: day 54
    边工作边刷题:70天一遍leetcode: day 55
    JavaScript 组件化开发之路(一)
    Promise
    HTML5 API 之 history
    时隔一年,window.scroll
    sublimeLinter-jshint 配置
  • 原文地址:https://www.cnblogs.com/DragonFire/p/6627439.html
Copyright © 2011-2022 走看看