python小象学院: BMR------ 基础代谢率4.0

博客可能围绕Python在基础代谢率(BMR)计算方面展开,借助Python工具和相关算法,实现对基础代谢率的精准计算,为相关研究或应用提供支持。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

""""
    auther:
    function:
    1.Calculating BMR
    2.Allow user input
    3.Allow user input by once
    version:v3.0
    data:2019/3/17
"""

def main():
    y_or_n = raw_input('Quit (y or n )?:')
    while y_or_n != 'y':

        print('Please enter the following information(separate with Spaces):')
        input_str=raw_input('Gender Weight(kg) Height(cm) Age: ')
        try:
            str_list = input_str.split(' ')
            str_list = input_str.split(' ')
            gender = str_list[0]
            weight = float(str_list[1])
            height = float(str_list[2])
            age = int(str_list[3])

            if gender == 'man':
                bmr = (13.7 * weight) + (5.0 * height) - (6.8 * age) + 66
            elif gender == 'woman':
                bmr = (9.6 * weight) + (1.8 * height) - (4.7 * age) + 665
            else:
                bmr = -1

            if bmr != -1:
                print 'Your gender: {} ,Your weight: {} ,Your height: {} ,Your age: {} '.format(gender,weight,height,age)
                print 'Your BMR is : {} cal'.format(bmr)
            else:
                print 'The gender is not supported for the time being!'
            print
            y_or_n = raw_input('Quit (y or n )?:')
        except ValueError:
            print 'Please enter the right infoemation!'
        except IndexError:
            print 'Input information too less!'
        except:
            print 'Error!'

if __name__== '__main__':
    main()


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值