class student:
def __init__(self,names,idno,ages,he ,we ):
self.names = names
self.idNo = idno
self.age = ages
self.weight = we
self.height = he
def display(self):
print('Name :',self.names,' ID NO.:',self.idNo,' Age :',self.age,' Weight :',self.weight,' Height :',self.height)
def get_height(self):
return self.height
def get_weight(self):
return self.weight
def setup():
a= [student('James',58001,13,177,90),
student('Jane',58002,15,140,60),
student('John',58003,17,156,54),
student('Jonas',58004,20,188,70)]
i=0
while(i<len(a)):
a[i].display()
print('BMI = %.2f'%cal_bmi(a,i))
print('this ',find_more_BMI(a,i),'has BMI >25')
print()
i=i+1
def cal_bmi(a,i):
while(i<len(a)):
n=0
w = a[i].get_weight()
h = a[i].get_height()
bmi=w/(h/100)**2
return bmi
def find_more_BMI(a,i):
n=0
if(cal_bmi(a,i)>25):
n='one'
else:
n='one not'
return n
setup()
ไม่มีความคิดเห็น:
แสดงความคิดเห็น