菜鸟的Python之路

Python( 五):If语句

2017-11-28  本文已影响0人  Tester_Jingel

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 '成年人'
上一篇 下一篇

猜你喜欢

热点阅读