BMI的计算
%%writefile BIM.py
class BMI:
def __init__(self,name,age,weight,high):
self.name = name
self.age = age
self.weight =weight
self.high = high
def print_bmi1(self):
getBMI=self.weight/(self.high*self.high)
print("{x}的BMI是".format(x=self.name))
if getBMI<18.5:
print("偏瘦")
elif getBMI< 24:
print("正常")
elif getBMI<30:
print("偏胖")
else:
print("肥胖")
该博客定义了一个BMI类,用于计算个人的体质指数并根据结果判断体型。通过输入体重和身高,程序会输出BMI值,并显示对应的体型状态,包括偏瘦、正常、偏胖和肥胖。
1万+

被折叠的 条评论
为什么被折叠?



