Exercise 13-1 Below are two classes that store some information about two different types of art...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Exercise 13-1 Below are two classes that store some information about two different types of art pieces, Paintings and Sculptures. Each class has an instance variable containing the artist's name (a string) named artist. However, Paintings have an area in square inches (a float), whereas Sculptures have a weight in pounds (a float). Both classes also have a method too_bulky which determines whether or not the piece of art is too large to go into the gallery, though this depends on the area for a Painting, or the weight for a Sculpture. class Painting: definit_ (self, artist, area): self.artist = artist self. area = area def too_bulky (self): return self.area> 1000 class Sculpture: definit__(self, artist, weight): self.artist = artist weight self.weight def too_bulky (self): = return self.weight > 500 Write a function display_artist(artist, art_list), that takes in an artist's name (artist), and a list of objects that are a mix of Paintings and Sculptures (art_list). The function should return a new list containing only the objects which both belong to the given artist and are not too bulky. Submit your code to Gradescope in a file called ex13-1.py. Constraint: Do NOT check whether each element is a Painting or a Sculpture; due to polymorphism this check is unnecessary. Examples (note that the memory locations in the representations of the Paintings/Sculpture objects, like 0x03B553E8, will not match) You will need to copy in the Painting and Sculpture classes if you want to test with the examples below.: >>> display_artist('Pablo', [Sculpture ('Mi', 120)]) [] >>> gallery = [Sculpture ('Mi', 120), Painting('Leo', 102), Painting('Mi', 1502), Sculpture ('Mi', 700), Painting('Mi', 740), Sculpture('Mi', 50)] >>> displayed display_artist('Mi', gallery) >>> displayed [ , , ] >>> displayed [0].weight 120 >>> displayed [1] .area 740 >>> displayed [2].weight 50 Exercise 13-1 Below are two classes that store some information about two different types of art pieces, Paintings and Sculptures. Each class has an instance variable containing the artist's name (a string) named artist. However, Paintings have an area in square inches (a float), whereas Sculptures have a weight in pounds (a float). Both classes also have a method too_bulky which determines whether or not the piece of art is too large to go into the gallery, though this depends on the area for a Painting, or the weight for a Sculpture. class Painting: definit_ (self, artist, area): self.artist = artist self. area = area def too_bulky (self): return self.area> 1000 class Sculpture: definit__(self, artist, weight): self.artist = artist weight self.weight def too_bulky (self): = return self.weight > 500 Write a function display_artist(artist, art_list), that takes in an artist's name (artist), and a list of objects that are a mix of Paintings and Sculptures (art_list). The function should return a new list containing only the objects which both belong to the given artist and are not too bulky. Submit your code to Gradescope in a file called ex13-1.py. Constraint: Do NOT check whether each element is a Painting or a Sculpture; due to polymorphism this check is unnecessary. Examples (note that the memory locations in the representations of the Paintings/Sculpture objects, like 0x03B553E8, will not match) You will need to copy in the Painting and Sculpture classes if you want to test with the examples below.: >>> display_artist('Pablo', [Sculpture ('Mi', 120)]) [] >>> gallery = [Sculpture ('Mi', 120), Painting('Leo', 102), Painting('Mi', 1502), Sculpture ('Mi', 700), Painting('Mi', 740), Sculpture('Mi', 50)] >>> displayed display_artist('Mi', gallery) >>> displayed [ , , ] >>> displayed [0].weight 120 >>> displayed [1] .area 740 >>> displayed [2].weight 50
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Ancient Indians did not believe in war and violence when it came it an expansion of political territory but relied on peaceful negotiation and strategy. Please explain your views on this quote with...
-
XO-20 is an oil-based product used to remove rust on bolts and nuts that are stuck. Its accounting system uses standard costs. The standards per .5-liter can of solution call for 0.75 liters of...
-
Emotional intelligence is more important than cognitive intelligence in influencing an individuals success. Do you agree or disagree with this statement? Support your perspective.
-
Verify that the fluctuating component of velocity (2D assumption) satisfies the following equation: \[\begin{equation*}\frac{\partial v_{x}^{\prime}}{\partial x}+\frac{\partial...
-
The following data come from the financial statements of Mitchell Company for the year ended March 31, 2015 (in millions): Requirements 1. Prepare a cash flow statement for the year ended March 31,...
-
The Expectancy theory concept of "expectancy" refers to what explain?
-
A penthouse condo in a high rise on the beach is purchased for $1.9MM and completely renovated in the year of purchase at a cost of $200,000. The depreciation period is 27.5 years. Calculate adjusted...
-
Describe the number -0.00061245 in floating-point representation, with the mantissa in two's complement.
-
Use the information given in Problem 24 to find: (a) P(A 1 |E) (b) P(A 2 |E) (c) P(A 3 |E) Data from Problem 24 Suppose that events A 1 , A 2 , and A 3 form a partition of the sample space S with P(A...
-
Discuss the distinct feature of an RRS filter with even and odd values of \(M\).
-
Show that if a filter bank has linear-phase analysis and synthesis filters with the same lengths \(N=L M\), then the following relations for the polyphase matrices are valid: \[\begin{aligned}&...
-
A lattice-like realization with second-order section allows the design of linear-phase two-band filter banks with even order where both \(H_{0}(z)\) and \(H_{1}(z)\) are symmetric. In this case...
-
Rene's Renovations Inc. is planning a major expansion program requiring $5,000,000 in financing. Option #1: Rene's may sell bonds with an 8% coupon rate, or Option #2: Rene's may sell 200,000 shares...
-
7 A 29-year-old, previously healthy man suddenly collapses at a party where legal and illicit drugs are being used. Enroute to the hospital, he requires resuscitation with defibrillation to establish...
-
Assume that n is 1. For each of the combinations of a, b, and c given at right, what is the value of n after each compound if statement? a. if (a b) { if (b c) { n = 2; } else { n = 3; } } b. if (a...
-
Pick a database system (such as DB2, Oracle, Postgres, or SQL Server) and determine from the web documentation: What JDBC driver do you need? Is it automatically discovered? What is the database...
-
Write a class Savings Account that is similar to the Bank Account class, except that it has an added instance variable interest. Supply a constructor that sets both the initial balance and the...
-
Quick return motion is incorporated in a shaper, a planer and ____.
-
Length of open belt connecting two pulleys of radii \(r_{1}\) and \(r_{2}\) and at a center distance \(D\) apart, is: (a) \(\pi\left(r_{1}+r_{2} ight)+\left(r_{1}-r_{2} ight)^{2} / D+2 D\) (b)...
-
A motor of \(5 \mathrm{~kW}\) running at \(950 \mathrm{rpm}\) is used in a riveting machine. A flywheel is attached to the machine has a mass of \(100 \mathrm{~kg}\) and radius of gyration of \(0.4...
Study smarter with the SolutionInn App