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)
时间: 2024-10-11 00:34:36