Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions

Question

Th ey have to wait a long time for an appointment?

Answered: 1 week ago

Question

Define span of management or define span of control ?

Answered: 1 week ago

Question

What is meant by formal organisation ?

Answered: 1 week ago

Question

What is meant by staff authority ?

Answered: 1 week ago

Question

Discuss the various types of policies ?

Answered: 1 week ago

Question

What about leadership lessons from particularly good or bad bosses?

Answered: 1 week ago

Question

When would you use one approach, and when would you use another?

Answered: 1 week ago