python小项目

def main():
    y_or_n = input(‘是否退出程序(y/n)?’)
    while y_or_n != ‘y’:
   
    #性别
        gender = input(‘请输入性别(gender):’)
        print(type(gender))
   
         #体重(kg)
        weight = float(input(‘请输入体重(weight):’))
        print(type(weight))
        #身高(cm)
        height = float(input(‘请输入身高(height):’))
        print(type(height))
        #年龄
        age = int(input(“请输入年龄(age):”))
        print(type(age))
        #男性
        if gender == ‘男’:
            bmr =( 13.7weight) + (5.0height) - (6.8age) + 66
        #女性
        elif gender == ‘女’:
            bmr = (9.6
weight)+ (1.8height) - (4.7age) + 655
        else:
            bmr = -1
           
           
        if bmr != -1:
            print(‘消耗的卡路里(大卡):’,bmr)
        else:
            print(‘不支持该类别’)
        print(’***********************************************’)
        y_or_n = input(‘是否退出程序(y/n)?’)
main()

你可能感兴趣的:(python小项目)