Make the following updates to the Array class, which is attach ed Download here Add an instance variable namedlogical_size whichtracks the array's logical size. Add a getter method to return this...



Make the following updates to the Array class, which is attach
ed


Download here




  1. Add an instance variable namedlogical_size whichtracks the array's logical size. Add a getter method to return this value to the client. Note: The len function should still return the array'sphysicalsize.

  2. Make the following changes to __setitem__:

    • If the client tries to update an index further than the first logically empty index of the array, raise an error.

      • i.e. if the arrayacontains [1, 2, None, None, None] and the user attempts a[3] = 10, this is an error!



    • If the client tries to set an index to None, make sure it is the last logically filled index of the array.

      • i.e. if an array's first 3 indexes have valid data in them, do not allow the client to say array[1] = None





  3. Add the method __eq__ to the Array class. Python runs this method when an Array object appears as the left operand of the == operator. The method should returns True if its argument is also an Array, it has the same logical size as the calling object, and the items at each correspondinglogicalindex in both Arrays are equal. Otherwise it should return False


After you have updated the Array class, write a simple driver program which demonstrates the use of the updated Array class.

Sep 17, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here