วันอาทิตย์ที่ 25 ตุลาคม พ.ศ. 2558

Find/count number of students with age < 30

def setup():
   name = ["AA", "BB", "CC"]
   ID = [54321, 12345, 51234]
   age = [15, 25, 35]
   weight = [70, 55, 60]
   height = [1.60, 1.75, 1.50]
   print(count(age))
 
def count(a):
   i = 0
   count = 0
   while(i < len(a)):
      if(a[i] < 30):
         count = count + 1
      i = i + 1
   return count

setup()

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

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