def __init__(self,name,weight,high,age,ID):
self.name = name
self.weight = weight
self.high = high
self.age = age
self.ID = ID
def show_data(self):
print("Name",self.name)
print("Weight",self.weight)
print("High",self.high)
print("Age",self.age)
print("ID",self.ID)
def get_weight(self):
return self.weight
def get_high(self):
return self.high
def calculation(data):
highM = data.get_high()/100
bmi = data.get_weight()/(highM*highM)
return bmi
def find_bmi(data):
index = 0
count = 0
while(index<len(data)):
if(calculation(data[index])>25):
count +=1
index = index + 1
return count
def setup():
index= 0
data = [student("Keane",50,185,18,1),
student("Giggs",55,175,19,2),
student("Nani",40,160,20,3),
student("Park",45,169,18,4),
student("Rooney",80,150,20,5)]
while(index<len(data)):
data[index].show_data()
print("BMI ",calculation(data[index]))
index = index + 1
print("The number of student that have bmi more than 25 is ",find_bmi(data))
setup()
ไม่มีความคิดเห็น:
แสดงความคิดเห็น