1. 程式人生 > >【Python】BMI國內測量

【Python】BMI國內測量

NPU RM eva mat 正常 elif form val put

shengao = eval(input(‘請輸入以米為單位的身高(例:1.75):‘))
tizhong = eval(input(‘請輸入以公斤為單位的體重(例:60):‘))
BMI = tizhong / (shengao**2)
if BMI<18.5:
print(‘BMI指數為{:.2f},偏瘦!‘.format(BMI))
elif 18.5<=BMI<24:
print(‘BMI指數為{:.2f},正常。‘.format(BMI))
elif 24<=BMI<28:
print(‘BMI指數為{:.2f},偏胖!‘.format(BMI))
else:
print(‘BMI指數為{:.2f},肥胖!該減肥了!‘.format(BMI))

【Python】BMI國內測量