get_top_regions() that takes three input parameters; the 2-D list (similar to the database), the dictionary that stores information of all regions, and a non-zero positive integer x. This function returns a new dictionary that contains the information of top-x regions in terms of the total number of hospitalization cases recorded in these regions. That means these top-x regions have the largest numbers of hospitalization cases. Each {key:value} pair in this resulting dictionary stores the name of a top region as the key and the value is the total number of hospitalization cases reported in this region. The result does not need to be sorted, the regions of the resulting dictionary can appear in any order as long as the top-x regions have been identified correctly. If the value of x is less than 1, or more than the total number of unique regions, your function should print a message informing the user and return an empty dictionary. See sample outputs below. >>> topx_regions = get_top_regions(database, regions, 4) >>> display_dict(topx_regions) atlantic: 1131 none: 3570 north: 856 prairie: 4594 >>> topx_regions = get_top_regions(database, regions, 2) >>> display_dict(topx_regions) none: 3570 prairie: 4594

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

get_top_regions() that takes three input parameters; the 2-D list (similar to the database), the dictionary that stores information of all regions, and a non-zero positive integer x. This function returns a new dictionary that contains the information of top-x regions in terms of the total number of hospitalization cases recorded in these regions. That means these top-x regions have the largest numbers of hospitalization cases. Each {key:value} pair in this resulting dictionary stores the name of a top region as the key and the value is the total number of hospitalization cases reported in this region.

The result does not need to be sorted, the regions of the resulting dictionary can appear in any order as long as the top-x regions have been identified correctly. If the value of x is less than 1, or more than the total number of unique regions, your function should print a message informing the user and return an empty dictionary. See sample outputs below.

  1. >>> topx_regions = get_top_regions(database, regions, 4) >>> display_dict(topx_regions) atlantic: 1131 none: 3570 north: 856 prairie: 4594

    >>> topx_regions = get_top_regions(database, regions, 2) >>> display_dict(topx_regions)
    none: 3570
    prairie: 4594

    >>> topx_regions = get_top_regions(database, regions, -5) >>> display_dict(topx_regions)
    The value of x is too low or too high.
    Dictionary is empty

 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY