效果图如下:
0: 体脂率不正常,偏瘦
1: 体脂率不正常,偏胖
0: 体脂率正常,身体健康
源码如下:
height=input("请输入您的身高(m)")
height=float(height)
weight=input("请输入您的体重(kg)")
weight=float(weight)
age=input("请输入您的年龄")
age=int(age)
sex=input("请输入您的性别(男:1,女:0)")
sex=int(sex)
if not(0<height<3 and 0<weight<300 and 0<age<150 and(sex==1 or sex==0)):
print("输入错误,请重新输入")
exit()
BMI=weight/(height*height)
TZL=1.2*BMI+0.23*age-5.4-10.8*sex
TZL/=100
if sex==1:
race=0.15<TZL<0.18
elif sex==0:
race=0.25<TZL<0.28
if sex==1:
wenhao="先生您好!"
Max=0.18
Min=0.15
elif sex==0:
Max=0.28
Min=0.25
wenhao="女士您好!"
if race:
tice="您的身体非常健康,继续保持!"
else:
tice="您的身体不正常,"
if TZL>Max:
rou="偏胖,多锻炼身体呦!"
elif TZL<Min:
rou="偏瘦,多补充营养呦!"
tice+=rou
print(wenhao+tice)
————————————————————————
Python
喜欢的点赞呦!