<p>以下是我的部分代码:</p>
<pre><code>students = 0
weight = 0
height = 0
while students < 5:
name = input("Please enter the name. ")
students = students + 1
while weight == 0:
try:
weight = float(input("Please enter the weight in kgs "))
if weight <= 0:
print ("Please enter a number greater than zero ")
weight = 0
continue
except ValueError:
print ("No number found, please enter a number greater than zero ")
weight = 0
continue
while height == 0:
try:
height = float(input("Please enter the height in metres "))
if height <= 0:
print ("Please enter a number greater than zero ")
height = 0
continue
except ValueError:
print ("No number found, please enter a number greater than zero ")
height = 0
continue
BMI = (weight/(height*height))
print (name, "has the BMI of", "%.2f" %BMI)
if BMI < 18.5:
print ("The student is underweight.")
elif 18.5 <= BMI <= 27:
print ("The student is a healthy weight.")
elif BMI > 27:
print ("The student is overweight.")
weight = 0
height = 0
</code></pre>
<p>然而,当BMI为18.5时,它表示学生体重不足,当BMI为27时,它表示学生超重,而实际上两者都应该是健康体重?
e、 体重为53.456克,身高为1.7米,显示体重不足</p>