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

Lab 6 : Display student records with BMI > 25

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

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

setup()

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

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