【python】基于中国BMI标准,通过输入身高,计算各个健康情况的体重范围

一、【python】计算各个健康情况的体重范围

1.1 效果演示

在这里插入图片描述

1.2 完整源代码

import sys
def BMIcounter():
    print('根据BMI中国标准和身高计算出各个健康标准的体重范围')
    try:
        height = float(input('请输入身高(如1.7)  :'))
    except:
        input('你输入了不正确的数值,请重新打开。')
        sys.exit(1)

    print('\n当小于{:.2f}kg时,您处于偏瘦状态'.format(18.4 * height ** 2))
    print('当处于{:.2f}kg 和{:.2f}kg之间时,您处于正常状态'.format(
        18.5 * height ** 2, 23.9 * height ** 2))
    print('当处于{:.2f}kg 和{:.2f}kg之间时,您处于过重状态'.format(
        24 * height ** 2, 27.9 * height ** 2))
    print('当大于{:.2f}kg 时,您处于肥胖状态'.format(28 * height ** 2))

if __name__ == "__main__":
    ifcontinue = True
    while(ifcontinue):
        BMIcounter()
        strContinue = input('\n... input any key to exit! or input 1 to continue counting.')
        ifcontinue = True if strContinue == '1' else False

参考博客

免费在线 BMI 计算器

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值