class BMI:
def __init__(self, weigth, height):
self.weigth = float(weigth)
self.height = float(height)
def print_BMI(self):
if self.height < 200:
change_height = float(self.height / 100)
if change_height <= 0:
raise ValueError
else:
BMI = self.weigth / (change_height * change_height)
print(f'BIM的值是:{BMI}')
if BMI < 16:
print("Underweight(Server thinness)")
elif 16.0 <= BMI <= 16.9:
print("Underweight(Moderate thinness)")
elif 17.0 <= BMI <= 18.4:
print("Mild thinness")
elif 18.5 <= BMI <= 24.9:
print("Normal range")
elif 25.0 <= BMI <= 29.9:
print("Overweight")
elif 30.0 <= BMI <= 34.9:
print("ClassI")
elif 35.0 <= BMI <= 39.9:
print("ClassII")
else:
print("ClassIII")
else:
print("-----输入不在范围,无法得出BMI属于的范畴!")
weigth = input("请输入您的体重(kg):")
height = input("请输入您的身高(cm):")
b_Data = BMI(weigth, height)
b_Data.print_BMI()