def setup():
floor_one = [10,25,30,55]
floor_two = [25,65,20,30]
floor_three = [15,25,40,45]
building = [floor_one,floor_two,floor_three]
print('Floor one has',totol_chairs(floor_one),'chairs')
print('Floor two has',totol_chairs(floor_two),'chairs')
print('floor three has',totol_chairs(floor_three),'chairs')
print('Total chairs are',total_chairs(building))
print('The number of maximum Chairs are in floor',max_floor(building))
print('The class that have maximum chairs is',find_max_class(building),'chairs')
def totol_chairs(floor_one):
index = 0
sum= 0
while(index < len(floor_one)):
sum += floor_one[index]
index += 1
return sum
def totol_chairs(floor_two):
index = 0
sum= 0
while(index < len(floor_two)):
sum += floor_two[index]
index += 1
return sum
def totol_chairs(floor_three):
index = 0
sum= 0
while(index < len(floor_three)):
sum += floor_three[index]
index += 1
return sum
def total_chairs(building):
allchairs = 0
index = 0
while(index<len(building)):
j = 0
while(j<len(building[index])):
allchairs = allchairs + building[index][j]
j = j + 1
index = index + 1
return allchairs
def max_floor(building):
max_floor = 0
index = 0
while(index<len(building)):
summation = 0
j = 0
while(j<len(building[index])):
summation = summation + building[index][j]
j = j + 1
if(summation>max_floor):
max_floor = index
index = index + 1
return max_floor
def find_max_class(building):
maximum = 0
index = 0
while(index < len(building)):
j = 0
while(j < len(building[index])):
if(building[index][j] > maximum):
maximum = building[index][j]
j = j + 1
index = index + 1
return maximum
setup()
ไม่มีความคิดเห็น:
แสดงความคิดเห็น