1.ǧ?千克千克?Դ??
ǧ??Դ??
按照题目要求编写的Python程序如下def calBMI(height,weight):
BMI=weight/(height*height)
if BMI<.5:
return [BMI,"过轻"]
elif BMI<:
return [BMI,"正常"]
elif BMI<:
return [BMI,"过重"]
else:
return [BMI,"肥胖"]
import re
s=input("请输入你的身高(米)和体重(公斤)逗号隔开:")
s1=re.split(r'[,,]',源码bigdecimal 源码s)
height=float(s1[0])
weight=float(s1[1])
name="李子健"
bmi=calBMI(height,weight)
print("{ }的测算结果为:".format(name))
print("BMI:%.2f"%bmi[0])
print(bmi[1])
源代码(注意源代码的缩进)