Demo entry 6667276

py

   

Submitted by anonymous on Nov 30, 2017 at 16:36
Language: Python 3. Code size: 468 Bytes.

# 输入数据,并将字符串类型转换为浮点数类型
height = input("请输入你的身高(m):")
height = float(height)
weight = input("请输入你的体重(kg):")
weight = float(weight)
age = input("请输入你的年龄:")
age = float(age)
sex = input("请输入你的性别(男:1,女:0):")
sex = float(sex)
# 计算体脂率
BMI = weight / (height * height)
TZL = 1.2 * BMI + 0.23 * age - 5.4 - 10.8 * sex
# 设置男女范围值
minNum = 0.15 + (1 - sex)
maxNum = 0.18 + (1 - sex)
result = minNum < TZL < maxNum
# 打印出结果
print("你的体脂率为%g"%(TZL),"是否符合标准:",result)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).