- 两个坑:
- 1.求bmi的时候,没说保留的格式,在中间计算过程种,不要round,否则不准
- 2.在判断的时候,先用小区间,else的时候为大区间,免得溢出问题
lines=[] while True: try: lines.append(input()) except: break # 定义计算bmi的函数 def bmi_1(w,h): h=h/100.0 bmi=w/(h**2) return bmi # 遍历数据,求得bmi,然后判断 for i in lines: w,h=map(int,i.split(" ")) x = bmi_1(w,h) if x < 18.5: print("Underweight") elif x <= 23.9: print("Normal") elif x <= 27.9: print("Overweight") else: print("Obese") # if x <=18.5 27.9: # print("Obese") # elif x>23.9: # print("Overweight") # elif x>=18.5: # print("Normal") # else: # print("Underweight")