16.判断条件样式一
[root@VM_0_6_centos py]# cat 15.py
#!/usr/bin/evo
#coding:utf-8
#print ('判断条件if')
age=input('please enter U age:')
if age >=18:
print('U age is',age)
print('adult')
elif age >=6:
print('U age is',age)
print('teenager')
else:
print('U age is',age)
print('kid')
[root@VM_0_6_centos py]# python 15.py
please enter U age:5
('U age is', 5)
kid
[root@VM_0_6_centos py]# python 15.py
please enter U age:11
('U age is', 11)
teenager
[root@VM_0_6_centos py]# python 15.py
please enter U age:27
('U age is', 27)
adult
16.同上
[root@VM_0_6_centos py]# python 16.py
请输入你的生日(年份):2010
00后
[root@VM_0_6_centos py]# python 16.py
请输入你的生日(年份):1989
00前
[root@VM_0_6_centos py]# cat 16.py
#!/usr/bin/evo
#coding:utf-8
s=input('请输入你的生日(年份):')
birth=int(s)
if birth < 2000:
print('00前')
else:
print('00后')
17.判断+input
[root@VM_0_6_centos py]# cat 17.py
#!/usr/bin/evo
#coding:utf-8
a=input('请输入身高(例如1.76):')
height=float(a)
b=input('请输入体重(例如80.5):')
weight=float(b)
MI=height*height
BMI=weight/MI
if BMI < 18.5:
print('过轻')
elif 18.5< BMI < 25:
print('正常')
elif 25< BMI < 28:
print('过胖')
elif 28< BMI < 32:
print('肥胖')
elif BMI > 32:
print('严重肥胖')
比如昨天刚想明白X=(1,2,[3,4]),X[2][0]
领取专属 10元无门槛券
私享最新 技术干货