美文网首页
003_if_else_多分支elif及缩进

003_if_else_多分支elif及缩进

作者: Nzkalhbxx | 来源:发表于2017-10-14 13:17 被阅读0次
    num = 21
    guessNum = int(input("input your num:"))
    # 判断语句后面必须接":"且判断条件内的语句必须有缩进,但不一定必须是缩进一个Tab,只需判断条件内的每条语句的缩进是一样的即可
    if guessNum == num:
        print("you got it~")
        print("you got it...")
        print("you get it!!!")
    else:
        print("sorry, you lost it")
        print("ou, you are out")
        print("bye bye")
    
    score = int(input("please input you score:"))
    if score > 90:
        print(">90,A")
    # elif是多分支if语句
    elif score > 80:
        print(">80,B")
    elif score > 60:
        print(">60,C")
    else:
        print("不合格,get out")
    
    运行结果

    相关文章

      网友评论

          本文标题:003_if_else_多分支elif及缩进

          本文链接:https://www.haomeiwen.com/subject/lmvxuxtx.html