class bmi:
def __init__(self,name,age,weight,height):
self.name=name
self.age=age
self.weight=weight
self.height=height
def say_hello1(self):
a=self.height**2
self_bmi=self.weight/a
print("{n}的BMI为{m}".format(n=self.name,m=self_bmi))
if self_bmi < 18.5 :
print ("偏瘦")
elif self_bmi < 24 :
print ("正常")
elif self_bmi < 30 :
print ("偏胖")
elif self_bmi > 30:
print ("肥胖")
name1=input("名字:")
age1=int(input("年龄:"))
weight1=float(input("体重:"))
height1=float(input("身高:"))
ps=bmi(name1,age1,weight1,height1)
ps.say_hello1()
python计算bmi
最新推荐文章于 2024-04-17 17:30:00 发布