Question: Read the docstring for remove, delete the raise statement, then implement the method. This method should reduce the bag s capacity when two - thirds

Read the docstring for remove, delete the raise statement, then implement the method. This
method should reduce the bags capacity when two-thirds or more of the backing array is not used.
(Hint: see class ArrayList.)
Note that:
When the bag is empty, the method should raise a ValueError exception that displays the
message, "bag.remove(x): remove from empty bag". The statement that does this is:
Lab 3: Array Bag SYSC 2100
Carleton University 4 Systems and Computer Engineering
raise ValueError("bag.remove(x): remove from empty bag")
When the bag has no occurrences of the item we want to remove, the method should raise a
ValueError exception that displays the message, "bag.remove(x): x not in bag"
Use the Python shell to run a few tests on remove.
Think about the test cases that would be required to thoroughly test remove. Implement these
test cases as methods in class RemoveTestCase. (Dont delete test remove1 and test remove2.)
Run the test script and review the output in the shell window. If necessary, edit remove and rerun
the test script until all test cases pass.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!