美文网首页菜鸟的Python之路
Python( 五):If语句

Python( 五):If语句

作者: Tester_Jingel | 来源:发表于2017-11-28 17:27 被阅读0次

    1、数学式:

    = < <= != / % ==

    2、关键字:
    and(同时满足)与or(满足一种即可)
    In 检查是否在列表内

    3、布尔表达式
    True False

    4、If语句
    If
    If-else
    If-elif-else

    # coding:utf-8
    user_input = input("please input you age")
    if user_input ==0:
        print "年龄不能为0"
    elif user_input <2:
        print u'他是婴儿'
    elif user_input >=2 and user_input <4:
        print u'他正在蹒跚学步'
    elif user_input >=4 and user_input<13:
        print '他是儿童'
    elif user_input >=13 and user_input<20:
        print '青年人'
    elif user_input>=20 and user_input<65:
        print '成年人'
    

    相关文章

      网友评论

        本文标题:Python( 五):If语句

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