python第一个程序:计算体脂率

主要是为了提醒自己要——保重

height = input('请输入身高(m):')
weight = input('请输入体重(KG):')
age = input('请输入年龄:')
sex = input('请输入性别(男:1,女:0):')

BMI = float(weight) / (float(height) * float(height))
per = 1.2 * BMI + 0.23 * int(age) - 5.4 - 10.8 * int(sex)

if sex == 1:
    if 15 > per > 18:
        print('体脂率为{0}合格'.format(str(per)))
    else:
        print('体脂率为{0}不合格'.format(str(per)))
else:
    if 25 < per < 28:
        print('体脂率为{0}合格'.format(str(per)))
    else:
        print('体脂率为{0}不合格'.format(str(per)))
原文地址:https://www.cnblogs.com/vichin/p/8877717.html