วันอังคารที่ 24 พฤศจิกายน พ.ศ. 2558

Lab 6 : Find/count number of students with BMI > 25

def setup():
   name = ["Mum" , "Teng" , "Nong" , "Tukky"]
   height = [161,175,177,155]
   weight = [62,54,86,71]
   age = [25,18,52,43]
   i = 0
   count = 0
   while(i<len(name)):
      if(bmi(weight,height,i)>25):
         count = count+1
         print("BMI = ","%.2f"%bmi(weight,height,i))
      i = i+1
   print("Total student BMI>25 = ",count)
 

def bmi(weight,height,i):
   h = height[i]/100
   bmi = weight[i]/(h*h)
   return bmi

setup()

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

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