Write a function called how_many, which returns the sum of the number of values associated with

A. Write a function called how_many, which returns the sum of the number of values associated with a

A.  Write a function called how_many, which returns the sum of the number of values 

associated with a dictionary.

T= animals = {‘L’:[‘Lion’],’D’:[‘Donkey’],’E’:[‘Elephant’]}

>>>print(how_many(animals))

 

B. Write a function ‘biggest’ which takes a dictionary as a parameter and returns the key

corresponding to the entry with the largest number of values associated with it.

>>>animals = {‘L’:[‘Lion’],’D’:[‘Donkey’,’Deer’],’E’:[‘Elepha

nt’]}

>>>biggest(animals)

>>>d #Since d contains two values

C. Write a function Count_Each_vowel which accepts string from a user. The function should

return a dictionary which contains the count of each vowel.

>>> Count_Each_vowel(“HELLO”)

>>>{‘H’:1, ‘E’:1, ‘L’:2 , ‘O’:2}

Leave a Reply

Your email address will not be published.