In the ArraySortedBag class of the arraysortedbag.py file, complete the following: Complete the implementation of the __eq__
Fantastic news! We've Found the answer you've been seeking!
Question:
In the ArraySortedBag class of the arraysortedbag.py file, complete the following:
- Complete the implementation of the __eq__ method discussed in this chapter.
- This method should run in no worse than linear time.
- Returns True if self equals other, or False otherwise.
To test your program run the test() method in the testbag.py file.
Your program's output should look like the following:
TestingThe list of items added is: [2013, 61, 1973] Expect 3: 3 Expect the bag's string: {61, 1973, 2013} Expect True: True Expect False: False Expect the items on separate lines: 61 1973 2013 Expect {}: {} Expect {}: {} Expect True: True Expect False: False Expect two of each item: {61, 1973, 2013, 61, 1973, 2013} Expect {}: {} Expect crash with KeyError: Traceback (most recent call last): File ".solution/testbag.py", line 43, in test(ArraySortedBag) File ".solution/testbag.py", line 39, in test b2.remove(99) File "/root/sandbox/.solution/arraybag.py", line 91, in remove raise KeyError(str(item) + " not in bag") KeyError: '99 not in bag'
Grading
Write your Python code in the code editor. Use the Run button to execute and run the code. To review your progress, open up the "Tasks" panel on the left to view the curated list of tasks for the project.
Once you are happy with the test results, click Submit and then the Confirm button to submit your project for grading.
Related Book For
Posted Date: