Luke Practice
unknown
plain_text
2 years ago
2.3 kB
17
Indexable
# 綜合健康計算機 (BMI BMR TDEE) def get_bmi(height, weight): bmi = float(weight/((height/100)**2)) return bmi def get_bmr(sex, height, weight, age): if sex == "男": bmr = float (66+(13.7*weight+5*height-6.8*age)) bmr = round (bmr,1) elif sex == "女": bmr = float (655+(9.6*weight+1.8*height-4.7*age)) bmr = round (bmr,1) return bmr def get_tdee(sex, height, weight, age, times): tdee = get_bmr(sex, height, weight, age)*times return tdee print ("歡迎使用綜合健康計算機 \n(1)計算BMI \n(2)計算基礎代謝率(bmr) \n(3)計算總熱量消耗(tdee)") project = input ("請選擇要計算的項目(請輸入1 or 2 or 3) \n") if project == "1": height = float (input ("請輸入您的身高(公分)\n")) weight =float (input ("請輸入您的體重(公斤) \n")) bmi=get_bmi(height, weight) bmi=round (bmi,2) print (f"您的BMI是{bmi}") elif project == "2": sex = (input ("請輸入您的性別(男 or 女)\n")) height = float (input ("請輸入您的身高(公分)\n")) weight =float (input ("請輸入您的體重(公斤) \n")) age = int (input ("請輸入您的年齡(歲) \n")) bmr = get_bmr(sex, height, weight, age) bmr=round (bmr,2) print (f"您的BMR是{bmr}") elif project == "3": sex = (input ("請輸入您的性別(男 or 女)\n")) height = float (input ("請輸入您的身高(公分)\n")) weight =float (input ("請輸入您的體重(公斤) \n")) age = int (input ("請輸入您的年齡(歲) \n")) times = int(input("請輸入符合您的活動量敘述 \n(1)久坐 幾乎沒運動 \n(2)每週運動1~3天 \n(3)每週運動3~5天 \n(4)每週運動6~7天 \n(5)勞力密集工作或高強度運動 \n(請輸入1-5間的整數) \n")) if times =="1": times= 1.2 elif times =="2": times= 1.375 elif times =="3": times= 1.55 elif times =="4": times= 1.725 elif times =="5": times= 1.9 else: print ("請輸入正確的活動量敘述") get_tdee(sex, height, weight, age, times) tdee = get_tdee(sex, height, weight, age, times) tdee=round (tdee,2) print (f"您的TDEE是{tdee}")
Editor is loading...