Take_Bmi=(input("Take bmi yes or no "))
if Take_Bmi == "yes":
name1=input(" enter your name")
height_m1=input(" enter your height in m")
weight_kg1=input(" enter your weight")
def bmi_calculator(name1,height_m1,weight_kg1):
bmi = float(weight_kg1) / (float(height_m1)** 2)
#输入函数返回一个字符串。所以要得到你的输出,你需要用 "float() "来表示身高和体重:print("bmi:")
if bmi < 25 :
print(bmi)
return name1 + " not overweight"
else:
print(bmi)
return name1 + " is overweight"
result= bmi_calculator(name1,float(height_m1),float(weight_kg1))
print(result)
else:
print("thank you")
该 input
函数返回一个字符串.所以为了得到你的输出,你需要使用 "float() "来表示高度和重量。
bmi = float(weight_kg1) / (float(height_m1)** 2)
同时,你还需要 召唤 你的函数,例如
bmi_calculator(name1,float(height_m1),float(weight_kg1))