love

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

Lab6 - Find total number of chairs in the building

def setup():
   floor_1 = [43 ,55 ,48]
   floor_2 = [33 ,20 ,25 ,38]
   floor_3 = [38 ,45 ,42 ,44 ,53]
   floor_4 = [50 ,50]
   building = [floor_1,floor_2,floor_3,floor_4]
   total_chair(building)
 
def total_chair(b):
   i = 0
   chair = 0
   while(i<len(b)):
      a = 0
      while(a<len(b[i])):
         chair = chair + b[i][a]
         a = a +1
      i = i+1
   print("Chair number in this building is ",chair)
 
setup()

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

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