Question: python dictionary 2. We have the following dictionary animals = { 'a': 'aardvark'), 'b': ['baboon', 'c': ['cat') } Notice that the key/value pairs of this

 python dictionary 2. We have the following dictionary animals = {
'a': 'aardvark'), 'b': ['baboon', 'c': ['cat') } Notice that the key/value pairs
python dictionary

2. We have the following dictionary animals = { 'a': 'aardvark'), 'b': ['baboon', 'c': ['cat') } Notice that the key/value pairs of this dictionary consist of: The key is a character (or string) The value is a list The animals Dictionary object is a dictionary where all the values are lists. 1 Consider the following sequence of expressions: animals - tha: 'aardvark'). *b*["baboon', 'c': 'cat']) animals['d'] - ['dog'i animals 'd'].append('donkey') animals 'd').append('dolphin' animals 'd').append('dormouse' Write some Python code that will count the number of animals in our dictionary and print each animal in the lists Sample output may look something like this; however, I leave it up to you for the text and formatting aardvark baboon cat dog donkey dolphin dormouse There are 7 animals in our dictionary 3. Consider the same code as in question (2) This time, write some Python code which will print the key corresponding to the entry with the largest number of values associated with the key. If there is more than one such entry, just print any one of the matching keys. It not necessary to print each key with the same largest number of values. C* Along with printing the largest number of animals in the list. print how many there are in the list. Sample output may look something like this; however, I leave it up to you for the text and formatting The key that contains the most number of animals is 'd' and it has 4 animals Be careful! Make sure you test your program so that it truly is returning the key that contains the most number of animals. Use different test data, if you have to

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!