Discuss / Python / 算是写对了,之前写成18.5 =< bmi,一直执行的时候报错,现在知道“=”应该写在"<"的右边。

算是写对了,之前写成18.5 =< bmi,一直执行的时候报错,现在知道“=”应该写在"<"的右边。

Topic source

Henry_Smith

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

!/usr/bin/env python

h = input('请输入身高(M): ') h = float(h) w = input('请输入体重(KG): ') w = float(w) bmi = w/(h*h)

if bmi < 18.5: print ('体重过轻!') elif 18.5 <= bmi <= 25: print ('身材很标准!') elif 25 <= bmi <= 28: print ('体重过重!') elif 28 <= bmi <= 32: print ('体重偏胖!') else: print ('严重肥胖!')


  • 1

Reply