วันจันทร์ที่ 26 ตุลาคม พ.ศ. 2558

Find/count number of students with weight < 50.

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_name(self):
      return self.name
   def get_weight(self):
      return self.weight
   
def setup():
   a = Students("Gun", 32075, 26, 90, 174)
   b = Students("Rit", 32078, 25, 80, 170)
   c = Students("Frame", 32080, 19, 48, 173)
   d = Students("Boat", 32057, 16, 70, 168)
   nukrean = [a, b, c, d]
   find(nukrean)
 
def find(nukrean):
   i = 0
   count = 0
   while(i < len(nukrean)):
      if(nukrean[i].get_weight() < 50):
         print(nukrean[i].get_name(),"weight = ",nukrean[i].get_weight())
         count = count + 1
      i = i + 1
   print("Have",count,"Students")
 
setup()

ไม่มีความคิดเห็น:

แสดงความคิดเห็น

Link Video Presentation Resort Managemant System Project.

Video Presentation Resort Managemant System Project. จัดทำโดย พากษ์เสียง: คุณาสิน  ทองมณี  5801012620011 ลำดับภาพ: สุพิชชา  ศรีศิริ...