用面向对象计算BMI指数

from __future__ import division
class Student:
    def __init__(self,name,weight,height):
        self.name=name
        self.weight=weight
        self.height=height
    @property
    def bmi(self):

        return [self.weight/(self.height**2),self.height*self.height]
name=input('姓名》》:')
T=input('体重(kg)》》:')
H=input('身高(m)》》:')
print(name,T,H)
s=Student(name,float(T),float(H))
print(s.height)
print('%s的BMI指数为:'%name,s.bmi)
原文地址:https://www.cnblogs.com/ldq1996/p/7780489.html