Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 5: Identify the Most Viral People We will define the most viral people as the people who likely infected the greatest number of other

Part 5: Identify the Most Viral People

We will define the most viral people as the people who likely infected the greatest number of other organisms in the data set. Identify and display all of the most viral people under an appropriate heading.

The output for Part 5 for DataSet1.txt should be:

Most Viral People: Bob

While DataSet1.txt has only one of these other inputs may have several viral individuals, who infected the same amount of people. When that situation occurs, your program should display all of these at the same quantity.

Below is the format list

## Format a list of items so that they are comma separated and "and" appears # before the last item. # Parameters: # data: the list of items to format # Returns: A string containing the items from data with nice formatting def formatList(data): # Handle the case where the list is empty if len(data) == 0: return "(None)" # Start with an empty string that we will add items to retval = "" # Handle all of the items except for the last two for i in range(0, len(data) - 2): retval = retval + str(data[i]) + ", " # Handle the second last item if len(data) >= 2: retval += str(data[-2]) + " and " # Handle the last item retval += str(data[-1]) # Return the result return retval # Run some tests if the module has not been imported if __name__ == "__main__": # Test the empty list values = [] print(values, "is formatted as", formatList(values)) # Test a list containing a single item values = [1] print(values, "is formatted as", formatList(values)) # Test a list containing two items values = [3, 4] print(values, "is formatted as", formatList(values)) # Test a list containing three items values = [-1, -2, -3] print(values, "is formatted as", formatList(values)) # Test a list containing four items values = ["Alice", "Bob", "Chad", "Diane"] print(values, "is formatted as", formatList(values)) # Test a list containing lots of items values = [3, 1, 4, 1, 5, 9, 2, 6, 5, 9] print(values, "is formatted as", formatList(values)) 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions

Question

What statement about the print ( ) function is true?

Answered: 1 week ago