Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Box.Py : The following class models a box. Just an ordinary, cardboard box. You can find the Python code on Canvas in box.py Notice that

image text in transcribed

Box.Py :

image text in transcribed

The following class models a box. Just an ordinary, cardboard box. You can find the Python code on Canvas in box.py Notice that three of this class's methods are "stubs," meaning that they are only place-holders and, so far, do not do anything setLimit(, empty), and tally() 1.) 4 points Write code for setLimit(). The method should receive an integer (let's call it x) and change the value of the attribute limit inside the Box. For 4 bonus points Add code to setLimit() that will check immediately whether the Box'?s contents are already in excess of the limit you just set. For example, if I've already put 5 things in the Box, and then I tell the Box that its limit is 3, it should print a warning to the screen. Something like, "Hey! I'm overflowing here!" 2.) 6 points Write code for empty). The method should not receive any arguments (except self, of course). This method represents turning your cardboard box upside-down and dumping out its contents. Meaning, it should reset the Box's internal attribute contents to an empty list, but it should also return a separate list that has all the same things that contents had Hint: this will involve first copying the list contents to a new list to be called stuff. This new list, stuff, is what the method returns For 4 bonus points There are several ways to copy a list, but you'll get X bonus points if you do it using a loop 3.) 10 points Write code for tally. This method creates and returns a dictionary object named inventory. The idea is that you can put duplicate items in a Box. This method should return a dictionary that tells you how many of each thing you have in the Box

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

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions

Question

What is job enlargement ?

Answered: 1 week ago

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago

Question

Which diagnostic test is most commonly used to confirm PROM?

Answered: 1 week ago

Question

What is the hallmark clinical feature of a molar pregnancy?

Answered: 1 week ago