Question: python 1 434 hayet there. *** Bryo Leys to start it to try stana La LI tereral) - taient(leri, ales ales are up wil instant,


1 434 hayet there. *** Bryo Leys to start it to try stana La LI tereral) - taient(leri, ales ales are up wil instant, vali 21 is gettino, vectores together what we wow the com Metinary. The winerys met What to provided ter than all ( Otellers ho The naryse who comes from desperando found. The two spend left and right and consum otherwise We have died was of the dictionary dans cet Thiement dan Wichis may hand ME de bote ca ou ADN Gate Gina Malart Antarieties the near dictionary We car that atta elas an We bemann VINY will 11 AM EL ht, 5) , -1, , ) 11 Sem 24 A/D) O 1 * Tests for integer division 2 30 - AD(a-8, b-6) // AD(-2, 6-4, 6-4) 4 check_equal(d, AD(2-4, b-1, C-8)) 5 We will let you also implement max_items and min_items properties. The value of these properties should be a pair, consisting of the maximum/minimum value, and of the set of keys that led to that value. The latter needs to be a set, because there are multiple key, value pairs where the value is maximal or minimal. To avoid wasting your time, we will have you implement only the max_items property. If the AD is empty. the property's value should be the pair (None, set()). [ 2 1 ### Exercise: Implement max_items 3 def ad_max_items(self): **Returns a pair consisting of the max value in the AD, and of the 5 set of keys that attain that value. This can be done in 7 lines of code. *** 6 # YOUR CODE HERE 4 7 8 # Remember the use of the property decorator. 9 AD.max_items - property(ad_max_items) 10 O 1 ### Tests for 'max_items 2 3 # For empty Ads, it has to return None as value, and the empty set as key set. 4 check_equal(AD() .max_items, (None, set())) 5 # Case of one maximum. 6 check_equal(AD(red=2, green=3, blue=1).max_items, (3, {'green'})) 7 # Case of multiple maxima. 8 check_equal (AD(red=2, yellow=3, blue=3, violet=3, pink=1).max_items, SI 3', ') (3, {'yellow', 'blue', 'violet' })) 9 10 We let multiplication and division to you to implement. ### Exercise: Implement multiplication and division def ad_mul(self, other): YOUR CODE HERE AD._mul_ - ad_mul Define below division, similarly, YOUR CODE HERE . And finally, define below INTEGER division YOUR CODE HERE wew Tests for multiplication # Note that the elements that are missing in the other dictionary # are assumed to be 1. d = AD(2-2, b=3) - AD(-4, C5) check_equal(d, AD(a=2, b=12, c#5)) 1 434 hayet there. *** Bryo Leys to start it to try stana La LI tereral) - taient(leri, ales ales are up wil instant, vali 21 is gettino, vectores together what we wow the com Metinary. The winerys met What to provided ter than all ( Otellers ho The naryse who comes from desperando found. The two spend left and right and consum otherwise We have died was of the dictionary dans cet Thiement dan Wichis may hand ME de bote ca ou ADN Gate Gina Malart Antarieties the near dictionary We car that atta elas an We bemann VINY will 11 AM EL ht, 5) , -1, , ) 11 Sem 24 A/D) O 1 * Tests for integer division 2 30 - AD(a-8, b-6) // AD(-2, 6-4, 6-4) 4 check_equal(d, AD(2-4, b-1, C-8)) 5 We will let you also implement max_items and min_items properties. The value of these properties should be a pair, consisting of the maximum/minimum value, and of the set of keys that led to that value. The latter needs to be a set, because there are multiple key, value pairs where the value is maximal or minimal. To avoid wasting your time, we will have you implement only the max_items property. If the AD is empty. the property's value should be the pair (None, set()). [ 2 1 ### Exercise: Implement max_items 3 def ad_max_items(self): **Returns a pair consisting of the max value in the AD, and of the 5 set of keys that attain that value. This can be done in 7 lines of code. *** 6 # YOUR CODE HERE 4 7 8 # Remember the use of the property decorator. 9 AD.max_items - property(ad_max_items) 10 O 1 ### Tests for 'max_items 2 3 # For empty Ads, it has to return None as value, and the empty set as key set. 4 check_equal(AD() .max_items, (None, set())) 5 # Case of one maximum. 6 check_equal(AD(red=2, green=3, blue=1).max_items, (3, {'green'})) 7 # Case of multiple maxima. 8 check_equal (AD(red=2, yellow=3, blue=3, violet=3, pink=1).max_items, SI 3', ') (3, {'yellow', 'blue', 'violet' })) 9 10 We let multiplication and division to you to implement. ### Exercise: Implement multiplication and division def ad_mul(self, other): YOUR CODE HERE AD._mul_ - ad_mul Define below division, similarly, YOUR CODE HERE . And finally, define below INTEGER division YOUR CODE HERE wew Tests for multiplication # Note that the elements that are missing in the other dictionary # are assumed to be 1. d = AD(2-2, b=3) - AD(-4, C5) check_equal(d, AD(a=2, b=12, c#5))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
