計算身體質量指數BMI
阿新 • • 發佈:2020-12-10
class BMI: def __init__(self,name,age,weight,height): self.name=name self.age=age self.weight=weight self.height=height def say_hello(self): self.shuchu=self.weight/(self.height*self.height) print("{n}的BMI值為{m}".format(n=self.name,m=self.shuchu)) m = self.shuchu if m < 18.5 : print ("偏瘦") elif m < 24 : print ("正常") elif m < 30 : print ("偏胖") elif m > 30: print ("肥胖")