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 weight(data):
weight = data.get_weight()
return weight
def find_minimum_weight(data):
index = 0
minimum =100
while(index<len(data)):
if(weight(data[index])< minimum):
minimum = weight(data[index])
index = index + 1
return minimum
def show_weight(data):
index = 0
while(index<len(data)):
if(weight(data[index])<50):
print(weight(data[index]),end = " ")
index = index + 1
def count_weight(data):
index = 0
count = 0
while(index<len(data)):
if(weight(data[index])<50):
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()
index = index + 1
print("Display the weight that less than 50 kg.")
show_weight(data)
print()
print("Number of students that have weight less than 50 kg. is ",count_weight(data))
print("The minimum weight is ",find_minimum_weight(data),"kg.")
setup()
ไม่มีความคิดเห็น:
แสดงความคิดเห็น