วันอาทิตย์ที่ 1 พฤศจิกายน พ.ศ. 2558

Lab6_DataAndWeight

def setup():
   names=["Jack",'John','James','Jane']
   idNo=['5801','5802','5803','5804']
   age=[18,32,15,41]
   weight=[40,69,72,49]
   height=[150,162,170,159]
   listthedata(names,idNo,age,weight,height)
   print('the minimum weight is ',findminW(names,weight))
   print('there are ',findMinWeiNumber(names,weight),'students < 50')
def listthedata(names,idNo,age,weight,height):
    i=0
    while(i<len(names)):
         if(weight[i]<50):
            print('Name : ',names[i],' ID NO.: ',idNo[i],' Age: ',age[i])
            print('Weight: ',weight[i],' Height: ',height[i],' BMI: %.2f'%cal_bmi(i,weight,height))
            print()
         i=i+1
def cal_bmi(i,weight,height):
   bmi=(weight[i])/((height[i]/100)**2)
   return bmi
def findminW(names,weight):
   i=0
   minimum=weight[0]
   while(i<len(weight)):
      if(minimum>weight[i]):
           minimum=weight[i]
      i=i+1
   return minimum
def findMinWeiNumber(names,weight):
   i=0
   sums=0
   while(i<len(names)):
      if(weight[i]<50):
         sums=sums+1
      i=i+1
   return sums
setup()

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

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