BMI Calculation Simple application for calculating Body Mass Index. 计算BMI指数的简单应用
()
| 10 | |
| 11 | |
| 12 | def main(): |
| 13 | """BMI Calculation |
| 14 | |
| 15 | Simple application for calculating Body Mass Index. |
| 16 | 计算BMI指数的简单应用 |
| 17 | """ |
| 18 | |
| 19 | put_markdown(t("""# Body Mass Index |
| 20 | |
| 21 | [Body mass index](https://en.wikipedia.org/wiki/Body_mass_index) (BMI) is a measure of body fat based on height and weight that applies to adult men and women. |
| 22 | |
| 23 | BMI Categories: |
| 24 | |
| 25 | | Category | BMI | |
| 26 | | -------------------- | ------------- | |
| 27 | | Severely underweight | BMI<14.9 | |
| 28 | | Underweight | 14.9≤BMI<18.4 | |
| 29 | | Normal | 18.4≤BMI<22.9 | |
| 30 | | Overweight | 22.9≤BMI<27.5 | |
| 31 | | Moderately obese | 27.5≤BMI<40 | |
| 32 | | Severely obese | BMI≥40 | |
| 33 | |
| 34 | ## BMI calculation |
| 35 | The source code of this application is [here](https://github.com/wang0618/PyWebIO/blob/dev/demos/bmi.py) |
| 36 | """, """# BMI指数 |
| 37 | |
| 38 | [`BMI指数`](https://baike.baidu.com/item/%E4%BD%93%E8%B4%A8%E6%8C%87%E6%95%B0/1455733)(Body Mass Index,BMI),是用体重千克数除以身高米数的平方得出的数字,是国际上常用的衡量人体胖瘦程度以及是否健康的一个标准。 |
| 39 | |
| 40 | 成年人的BMI值处于以下阶段 |
| 41 | |
| 42 | | 体形分类 | BMI值范围 | |
| 43 | | ------ | -------- | |
| 44 | | 极瘦 | BMI<14.9 | |
| 45 | | 偏瘦 | 14.9≤BMI<18.4 | |
| 46 | | 正常 | 18.4≤BMI<22.9 | |
| 47 | | 过重 | 22.9≤BMI<27.5 | |
| 48 | | 肥胖 | 27.5≤BMI<40 | |
| 49 | | 非常肥胖 | BMI≥40 | |
| 50 | |
| 51 | ## BMI指数计算器 |
| 52 | 本程序的源代码[链接](https://github.com/wang0618/PyWebIO/blob/dev/demos/bmi.py) |
| 53 | |
| 54 | """)) |
| 55 | |
| 56 | info = input_group(t('BMI calculation', '计算BMI:'), [ |
| 57 | input(t("Your Height(cm)", "请输入你的身高(cm)"), name="height", type=FLOAT), |
| 58 | input(t("Your Weight(kg)", "请输入你的体重(kg)"), name="weight", type=FLOAT), |
| 59 | ]) |
| 60 | |
| 61 | BMI = info['weight'] / (info['height'] / 100) ** 2 |
| 62 | |
| 63 | top_status = [(14.9, t('Severely underweight', '极瘦')), (18.4, t('Underweight', '偏瘦')), |
| 64 | (22.9, t('Normal', '正常')), (27.5, t('Overweight', '过重')), |
| 65 | (40.0, t('Moderately obese', '肥胖')), (float('inf'), t('Severely obese', '非常肥胖'))] |
| 66 | |
| 67 | for top, status in top_status: |
| 68 | if BMI <= top: |
| 69 | put_markdown(t('Your BMI: `%.1f`, Category: `%s`', '你的 BMI 值: `%.1f`,身体状态: `%s`') % (BMI, status)) |
nothing calls this directly
no test coverage detected
searching dependent graphs…