In [14]:
personHeight = input('请输入你的身高(m):')
personHeight = float(personHeight)
personWeight = input('请输入你的体重(kg):')
personWeight = float(personWeight)
personAge = input('请输入你的年龄:')
personAge = int(personAge)
personSex = input('请输入你的性别(0代表女性,1代表男性):')
personSex = int(perspnSex)
请输入你的身高(m):1.75
请输入你的体重(kg):68
请输入你的年龄:23
请输入你的性别(0代表女性,1代表男性):1
In [15]:
if not(0<personWeight<300 and 0<personHeight<3 and 0<personAge<150 and (perspnSex == 0 or perspnSex == 1)):
print('数据不满足要求,程序推出')
exit()
BMI = personWeight/(personHeight**2)
TZL = 1.2*BMI+0.23*personAge-5.4-10.8*perspnSex
TZL /= 100
if personSex == 1:
result = 0.15 < TZL < 0.18
elif personSex == 0:
result = 0.25 < TZL < 0.28
In [16]:
TZL
Out[16]:
0.15734897959183672
In [21]:
if personSex == 1:
wenhao = '先生你好'
minnum = 0.15
maxnum = 0.18
elif personSex == 0:
wenhao = '女士你好'
minnum = 0.25
maxnum = 0.28
if result:
notice = '恭喜你,身体非常健康,请继续保持'
else:
if TZL > maxnum:
notice = '请注意,您的身体不正常,偏胖'
else:
notice = '请注意,您的身体不正常,偏瘦'
In [22]:
print(wenhao,notice)
先生你好 恭喜你,身体非常健康,请继续保持