Question: Write an algorithm that creates a Ragged Grid with four rows. The first row has 3 positions, the second row has 4 positions, the third
Write an algorithm that creates a Ragged Grid with four rows. The first row has 3 positions, the second row has 4 positions, the third row includes 6 positions, and the fourth row contains 1. You can modify the iArray ADT defined below or use any standard library to implement your algorithm.
class iArray():
def __init__(self, capacity, fillValue = None):
self._items = list()
for count in range(capacity):
self._items.append(fillValue)
def __len__(self):
return len(self._items)
def __str__(self):
return str(self._items)
def __iter__(self):
return iter(self._items)
def __getitem__(self, index):
return self._items[index]
def __setitem__(self, index, newItem):
self._items[index] = newItem
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
