Question

In python Complete the function mostCommonCount() so that will accept a list of names as a...

In python Complete the function mostCommonCount() so that will accept a list of names as a parameter, and return the count of the most common name in the list.

Examples:
mostCommonCount( ['marquard', 'zhen', 'csev', 'zhen', 'cwen', 'marquard', 'zhen', 'csev', 'cwen', 'zhen', 'csev', 'marquard', 'zhen'] ) returns 5
mostCommonCount( ['Jacob', 'Michael', 'Joshua', 'Matthew', 'Emily', 'Madison', 'Emma', 'Olivia', 'Hannah'] ) returns 1
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Source code :-

import statistics
from statistics import mode
def mostCommonCount(List):
word=mode(List)
count=0
for i in list:
if word==i:
count+=1
return(count)
  
List = ['marquard', 'zhen', 'csev', 'zhen', 'cwen', 'marquard', 'zhen', 'csev', 'cwen', 'zhen', 'csev', 'marquard', 'zhen']
print(mostCommonCount(List))

for indentation, please refer to the image.

Add a comment
Know the answer?
Add Answer to:
In python Complete the function mostCommonCount() so that will accept a list of names as a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Python, Complete the extraCreditTotal() function to take a list of grades as a parameter and...

    In Python, Complete the extraCreditTotal() function to take a list of grades as a parameter and return the total number points above 100. Examples: extraCreditTotal( [101, 83, 107, 90] ) returns 8 (because 1 + 0 + 7 + 0 is 8) extraCreditTotal( [89, 113, 95] ) returns 13 extraCreditTotal( [89, 73, 96, 97, 99, 100] ) returns 0

  • Python 3.7.3 ''' Problem 3 Write a function called names, which takes a list of strings...

    Python 3.7.3 ''' Problem 3 Write a function called names, which takes a list of strings as a parameter. The strings are intended to represent a person's first and last name (with a blank in between). Assume the last names are unique. The function should return a dictionary (dict) whose keys are the people's last names, and whose values are their first names. For example: >>> dictionary = names([ 'Ljubomir Perkovic', \ 'Amber Settle', 'Steve Jost']) >>> dictionary['Settle'] 'Amber' >>>...

  • In Python Complete the function powersOf5(). Have the function take a parameter n and return a...

    In Python Complete the function powersOf5(). Have the function take a parameter n and return a list of the first n powers of 5. One way to calculate powers of 5 is by starting with 1 and then multiplying the previous number by 5. Examples: powersOf5( 1 ) returns [1] powersOf5( 2 ) returns [1, 5] powersOf5( 3 ) returns [1, 5, 25] powersOf5( 6 ) returns [1, 5, 25, 125, 625, 3125] powersOf5( 10 ) returns [1, 5, 25,...

  • The text files boynames.txt and girlnames.txt, which are included in the source code for this boo...

    The text files boynames.txt and girlnames.txt, which are included in the source code for this book, contain lists of the 1,000 most popular boy and girl names in the United States for the year 2005, as compiled by the Social Security Administration. These are blank-delimited files where the most popular name is listed first, the second most popular name is listed second, and so on to the 1,000th most popular name, which is listed last. Each line consists of the...

  • Need help with the code for this assignment. Python Assignment: List and Tuples We will do...

    Need help with the code for this assignment. Python Assignment: List and Tuples We will do some basic data analysis on information stored in external files. GirNames.txt contains a list of the 200 most popular names given to girls born in US from year 2000 thru 2009: (copy link and create a txt file): https://docs.google.com/document/d/11YCVqVTrzqQgp2xJqyqPruGtlyxs2X3DFWn1YUb3ddw/edit?usp=sharing BoyNames.txt contains a list of the 200 most popular names given to boys born in US from year 2000 thru 2009 (copy link and create...

  • write a function: Names(path): that reads from a file at location path and returns a dictionary...

    write a function: Names(path): that reads from a file at location path and returns a dictionary mapping from column names to lists containing the data in those columns. The format of the file is a csv file. The first line is a comma separated set of string names for the columns contained in the file. The function will accumulate a dictionary mapping from year to the list of years, from name to the list of names (in the same order),...

  • PLEASE DO THIS WITH PYTHON! Please do this with PYTHON! Assume the example of a name...

    PLEASE DO THIS WITH PYTHON! Please do this with PYTHON! Assume the example of a name list for all problems below (use it as a line in your code) e.g. nameist -ll'Julia Truong'.'Chen Wu'vJeb Castro,'Ron Kennedy', 'X YI 1. Write a recursive function convertNames0 to accept the initial nameList and return a new list containing only first names. Provide function call and print the resulting list after the function had returned the results. (solution similar to problem on the slide...

  • In python,write a function nameSet(first, last) that takes a person's first and last names as input,...

    In python,write a function nameSet(first, last) that takes a person's first and last names as input, and returns a tuple of three strings: the first string gives the union of all letters in the first and last names (no duplication though). The second string gives the intersection of letters in the first and last names, i.e. the common letters. If there are no common letters, then the second string is empty (''). The third string gives the symmetric difference between...

  • How to do this code? HW13.11. Create an HTML list from a Python list The function...

    How to do this code? HW13.11. Create an HTML list from a Python list The function below takes one parameter: a list, that contains only strings. Complete the function to create a unordered HTML list, as a string, and returns it. An empty list should return an empty HTML list with no list items. Do not add any extraneous whitespace to the HTML. For example, if given the list ["one", "two"], the function should return "<ul><li>one</li><li>two</li> </ul>". student.py IT TI...

  • python Days of the Week Function Name: days_of_the_week() Parameters: list of birthdays ( list ), year...

    python Days of the Week Function Name: days_of_the_week() Parameters: list of birthdays ( list ), year (int ) Returns: list of names ( list ) Description: You and your friends all want to celebrate your birthdays together, but you don't want to stay up late on a school night. Write a function that takes in a list of tuples formatted as (day ( int ), month ( int ), name (string)), and a year ( int ). Use Python's calendar...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT