python函数写bmi python函数写在不同文件里

求一道Python题,是关于定义函数和身体指数的,谢谢各位大神啦!!!

按照题目要求编写的Python程序如下

10年积累的成都做网站、网站制作、成都外贸网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站制作后付款的网站建设流程,更有龙里免费网站建设让你可以放心的选择与我们合作。

def calBMI(height,weight):

BMI=weight/(height*height)

if BMI18.5:

return [BMI,"过轻"]

elif BMI24:

return [BMI,"正常"]

elif BMI28:

return [BMI,"过重"]

else:

return [BMI,"肥胖"]

import re

s=input("请输入你的身高(米)和体重(公斤)【逗号隔开】:")

s1=re.split(r'[,,]',s)

height=float(s1[0])

weight=float(s1[1])

name="李子健"

bmi=calBMI(height,weight)

print("{}的测算结果为:".format(name))

print("BMI:%.2f"%bmi[0])

print(bmi[1])

源代码(注意源代码的缩进)

python语言计算BMI值,感谢求解!

sg = input('你的身高多少(米):')

tz = input('你的体重多少(公斤):')

BMI = round(float(tz) / float(sg) ** 2, 1)

if BMI  18.5:

print('BMI={0},{1}'.format(BMI, '偏瘦'))

elif 18.5 = BMI  24.9:

print('BMI={0},{1}'.format(BMI, '标准'))

elif 25.0 = BMI  29.9:

print('BMI={0},{1}'.format(BMI, '超重'))

elif 25 = BMI:

print('BMI={0},{1}'.format(BMI, '肥胖'))

这是委托我读五年级的儿子写的。^_^

怎样用python计算bmi

weight=int(raw_input("请输入体重(千克):"))

height=int(raw_input("请输入身高(米):"))

BMI=weight/(height*height)

print "BMI=",BMI

if  BMI19:

print“轻体重"

elif  BMI=19 and BMI25:

print"健康身体"

elif BMI=25 and BMI28:

print"超重“

else:

print"肥胖”

raw_input("press any key to quit.")


标题名称:python函数写bmi python函数写在不同文件里
本文路径:http://myzitong.com/article/dopogcs.html