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 twothirds 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.removex: remove from empty bag". The statement that does this is:
Lab : Array Bag SYSC
Carleton University Systems and Computer Engineering
raise ValueErrorbagremovex: 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.removex: 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 remove and test remove
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
