Sunday, November 1, 2015

Lab7 - Find minimum weight of students

class Student:

    def __init__(self,name,id,age,weight,height):
       

        self.name = name

        self.id = id

        self.age = age

        self.weight = weight

        self.height = height


    def display_name(self):
        return self.name
       
    def display_id(self):
        return self.id 
       
    def display_age(self):
        return self.age
       
    def display_weight(self):
        return self.weight
       
    def display_height(self): 
        return self.height

      

def setup():

    a = Student( "Antony" , 11 , 22 , 58 , 165 )

    b = Student( "Mike" , 12 , 23 , 66 , 171 )

    c = Student( "Jacky" , 23 , 21 , 71 , 162 )

    d = Student( "Bank" , 30 , 22 , 57 , 177 )

    e = Student( "Billy" , 1 , 20 , 62 , 180 )

    f = Student( "Biccy" , 3 , 24 , 62 , 181 )

    data = [a,b,c,d,e,f]

    find_minimum(data)


def find_minimum(data):
   
    i=0
   
    reference=data[i].display_weight()
   
    while(i < len(data)):
       
        if(reference>data[i].display_weight()):
           
            reference=data[i].display_weight()
           
        i+=1
       
    print("Minimum weight of students is ",reference)   


setup()

No comments:

Post a Comment