Question: 1. (4pts) Write a count_family(name_list) function. This function returns a dictionary with keys being the unique last names and values being the number of

1. (4pts) Write a count_family(name_list) function. This function returns a dictionary with keys being the 

1. (4pts) Write a count_family(name_list) function. This function returns a dictionary with keys being the unique last names and values being the number of names with the corresponding last name. For example, "Alex Foo" and "Chris Foo" have the same last name. When calling count_family(["Alex Foo", "Chris Foo"]), the return value should be {"Foo":2}. When calling count_family(["Alex Foo", "Ben Bar", "Chris Foo", "Zella Brown", "Allen Fow", "Bob Foo", "Zoe Boo"], the returned dictionary should be {'Foo': 3, 'Bar': 1, 'Brown': 1, 'Fow': 1, 'Boo': 1}. 2. (4pts) Write a count_initials (name_list) function. This function returns a dictionary with the numbers of names with the same initials. The keys are the unique initials in the list. The values are the number of times each pair of initials appears in the list. For example, "Alex Foo" and "Allen Fow" have the same initials. When calling count_initials(["Alex Foo", "Allen Fow"]), the function should return {"AF":2}. When calling count_initials(["Alex Foo", "Ben Bar", "Chris Foo", "Zella Brown", "Allen Fow", "Bob Foo", "Zoe Boo"]), the returned dictionary should be {'AF': 2, 'BB': 1, 'CF': 1, 'ZB': 2, 'BF': 1} 3. (4pts) Write a most frequent_lastname(name_list) function. This function returns a dictionary of the most frequent last name. The returned dictionary only has one key-value pair. The key is the last name with the highest appearance time. You can assume there is going to be only one such name. The value is the number of times this last name appears in the list. For example, when the name list is ["Alex Foo", "Ben Bar", "Chris Foo"], the most frequent last name is "Foo", the function should return {"Foo":2}. When calling most frequent_lastname(["Alex Foo", "Ben Bar", "Chris Foo", "Zella Brown", "Allen Fow", "Bob Foo", "Zoe Boo"]), the returned dictionary should be {'Foo': 3}

Step by Step Solution

3.44 Rating (167 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The detailed answer for the above question is provided below Answer 1 Write a countfamilynamelist function def countfamilynamelist lastnamecount for fullname in namelist Split the full name into first ... View full answer

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 Programming Questions!