วันเสาร์ที่ 24 ตุลาคม พ.ศ. 2558

lab 6 find display and count bmi

def setup():
    name = ["Keane","Giggs","Cole","Scholes","Park","Nani"]
    student_number = [1,2,3,4,5,6]
    age = [35,19,18,20,19,31]
    high = [177,182,170,169,185,160]
    weight = [95,50,90,75,60,48]
    data = [student_number,age,high,weight,name]
    find_bmi(student_number,name,weight,high)
    print('There are',count_bmi(student_number,name,weight,high),'students that have BMI more than 25')
def find_bmi(student_number,name,weight,high):
        index = 0
        bmi = 0
        count = 0
        while(index<len(student_number)):
            bmi = weight[count]/((high[count]/100)*2)
            count  = count + 1
            print('BMI of ',name[index],bmi)
            index = index + 1
def count_bmi(student_number,name,weight,high):
        index = 0
        bmi = 0
        count = 0
        while(index<len(student_number)):
            bmi = weight[index]/((high[index]/100)*2)
            if(bmi>25):
                count += 1
            index = index + 1
        return count
                           
setup()

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

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