python3练习:简单函数(BMI)
#简单写个函数,计算BMI def fun_bmi (name,height,weight): ''' 计算BMI :param name: 姓名 :param height: 身高 :param weight: 体重 :return: none ''' bmi = weight/2/(height*height) #BMI公式 #print (name,'身高:',height,"体重:",weight,',对应BMI为:',bmi, end=',') #bmi结果过长 print (name,'身高:',height,"体重:",weight,',对应BMI为:%.2f' %bmi, end=',') #BMI2位小数显示出来,且end=','表示不换行,以,结束 if bmi >= 29.9: print (name+"该减肥了~") elif bmi >= 24.9: print(name+"尚可,但在演艺圈的话可以瘦一些~") elif bmi >= 18.5: print(name+"在普通人中是健康的,是否要再瘦些看本人意愿~") elif bmi > 18: print(name+"在贵圈中很标准,也勉强算健康哟") elif bmi > 17.9: print(name+"太瘦啦,想说:健康最重要啊") else: print(name + ",这身体是有病呀