觉得题目的要求是同时满足两个条件
w=float(input('please input your weight(kg): ')) h=float(input('please input your height(m): ')) BMI=w/(h*h) if BMI<=18.5: print('过轻') elif BMI<=25 and BMI>18.5: print('正常') elif BMI<=28 and BMI>25: print('过重') elif BMI<=32 and BMI>28: print('肥胖') else: print('严重肥胖')
elif已经包含了对之前条件的判断,只有在前面条件不通过的情况下才会继续执行判断,所以不需要再加上and后面的这个条件了。
Sign in to make a reply
小丑先生不爱笑
觉得题目的要求是同时满足两个条件
-- coding: utf-8 --
w=float(input('please input your weight(kg): ')) h=float(input('please input your height(m): ')) BMI=w/(h*h) if BMI<=18.5: print('过轻') elif BMI<=25 and BMI>18.5: print('正常') elif BMI<=28 and BMI>25: print('过重') elif BMI<=32 and BMI>28: print('肥胖') else: print('严重肥胖')