身體質量指數 (Body Mass Index, 簡稱BMI), 亦稱克托萊指數, 是目前國際上常用的衡量人體胖瘦程度以及是否健康的一個標准。BMI 值超標,意味着你必須減肥了。
在線版:https://cn.onlinebmicalculator.com/
代碼:
height,weight=eval(input("請輸入身高(米)和體重\(公斤)[用逗號隔開]:")) bmi=weight/pow(height,2) print("BMI數值為:(:.2f)".format(bmi)) who,nat="","" if bmi<18.5: who,nat="偏瘦","偏瘦" elif 18.5<=bmi<24: who,nat="正常","正常" elif 24<=bmi<25: who,nat="正常","偏胖" elif 25<=bmi<28: who,nat="偏胖","偏胖" elif 28<=bmi<30: who,nat="偏胖","肥胖" else: who,nat="肥胖","肥胖" print("BMI 指標為國際'{0}',國內'{1}'".format(who,nat))
結果: