Discuss / Python / h20220701

h20220701

Topic source

留君于心

#1 Created at ... [Delete] [Delete and Lock User]

height = float(input('height: '))

weight = float(input('weight: '))

BMI = weight/(height**2)

if BMI <18.5:

    print('过轻')

elif 18.5 <= BMI <=25:

    print('正常')

elif 25 <= BMI <= 28:

    print('过重')

elif 28 <= BMI <= 32:

    print('肥胖')

else:

    print('严重肥胖')

幽海暝蓝

#2 Created at ... [Delete] [Delete and Lock User]

bmi = 25和28的时候你觉得输出的结果是啥?

留君于心

#3 Created at ... [Delete] [Delete and Lock User]

C:\work>python age.py

height: 1

weight: 25

正常

C:\work>python age.py

height: 1

weight: 28

过重

留君于心

#4 Created at ... [Delete] [Delete and Lock User]

代码不够严谨,不过输出结果是由上往下的,上面条件符合就直接输出了


  • 1

Reply