class Students:
def __init__(self,name,ID,age,weight,height):
self.name = name
self.ID = ID
self.age = age
self.weight = weight
self.height = height
def get_age(self):
return self.age
def setup():
a = Students("Gun", 32075, 26, 90, 174)
b = Students("Rit", 32078, 25, 80, 170)
c = Students("Frame", 32080, 19, 58.2, 173)
d = Students("Boat", 32057, 16, 70, 168)
nukrean = [a, b, c, d]
count(nukrean)
def count(nukrean):
i = 0
count = 0
while(i < len(nukrean)):
if(nukrean[i].get_age() < 30):
count = count + 1
i = i + 1
print("Have",count,"Students")
setup()
ไม่มีความคิดเห็น:
แสดงความคิดเห็น