Monday, October 19, 2015

Lab 6 - Find average age of students

def setup():
    name = ["Ant", "Bird" ,"Cat" ,"Dog" ,"Elephant" ,"Frog" ,"Giraffe"]
    id = [19, 23 ,10 ,13 ,22 ,25 ,17]
    age = [18 ,17 ,16 ,19 ,18 ,18 ,17]
    weight = [69, 76 ,60 ,80 ,55 ,55 ,50]
    height = [165, 170 ,172 ,188 ,166 ,158 ,160]
    print("---Student records (data)---")
    print("")
    cal_average_age(age)

def cal_average_age(age):
    i=0
    summ=0
    while(i < len(age)):
        summ=summ+age[i]
        i+=1
    summ=summ/len(age)
    print("Average age of students : ",summ)
     
setup()

No comments:

Post a Comment