Sunday, November 1, 2015

Lab7 - Find student BMI

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(self):
        print("Name : ",self.name)
        print("Weight : ",self.weight)
        print("Height : ",self.height)
     
    def bmi(self):
        bmi=self.weight/((self.height/100)*(self.height/100))
        print("Your BMI is" ,bmi)
     
def setup():
    a = Student( "Antony" , 11 , 22 , 65 , 165 )
    b = Student( "Mike" , 12 , 23 , 66 , 171 )
    c = Student( "Jacky" , 23 , 21 , 58 , 162 )
    d = Student( "Bank" , 30 , 22 , 60 , 177 )
    e = Student( "Billy" , 1 , 20 , 62 , 180 )
    f = Student( "Biccy" , 3 , 24 , 62 , 181 )
    data = [a,b,c,d,e,f]
    bmi(data)

def bmi(data):
    i=0
    print("#### BMI ####")
    while(i < len(data)):
        data[i].display()
        data[i].bmi()
        print("")
        i+=1

setup()

No comments:

Post a Comment