# 静态方法
# height = 1.75
# weight = 80.5
# 动态方法
height = input('请输入height:')
weight = input('请输入weight:')
height = float(height)
weight = float(weight)
# bmi计算公式 height*height = height**2
bmi = weight/(height*height)
# 通过f-string的方法输出保留小数点后两位
print(f'bmi指数为:{bmi:.2f}')
if bmi > 18.5:
print('过轻')
elif bmi >= 18.5 and bmi < 25:
print('正常')
elif bmi >= 25 and bmi < 28:
print('过重')
elif bmi >= 28 and bmi < 32:
print('肥胖')
else:
print('严重肥胖')
Sign in to make a reply
Black
# 静态方法
# height = 1.75
# weight = 80.5
# 动态方法
height = input('请输入height:')
weight = input('请输入weight:')
height = float(height)
weight = float(weight)
# bmi计算公式 height*height = height**2
bmi = weight/(height*height)
# 通过f-string的方法输出保留小数点后两位
print(f'bmi指数为:{bmi:.2f}')
if bmi > 18.5:
print('过轻')
elif bmi >= 18.5 and bmi < 25:
print('正常')
elif bmi >= 25 and bmi < 28:
print('过重')
elif bmi >= 28 and bmi < 32:
print('肥胖')
else:
print('严重肥胖')