Answered step by step
Verified Expert Solution
Question
1 Approved Answer
find_all years (db) : This function accepts an existing database db, finds all years included in it anywhere. Return the list of years sorted in
find_all years (db) : This function accepts an existing database db, finds all years included in it anywhere. Return the list of years sorted in ascending order. total count_for_name (db, name, gender) : This function accepts an existing database db, a name and a gender, adds all counts for that name/gender from different years and returns the total. . names_by_ year(db, year): accepts a database db, and a year. It builds/returns a new database with only names (of either gender) with a count in the specified year and only information for that year. The original database must not be modified. . largest count_for_year(db, year): accepts a database db, and a year. It finds the name/gender pair(s) with the highest count in that year and returns as a list of tuples (name, gender, count). Since multiple name/gender pairs might tie with the highest count, sort the list alphabetically with .sort() or sorted() . add_name (db, name, gender, year, count, rank-None): This function accepts an existing database db, name, gender, year, count, and rank then it updates the database to include that information . Return None. The resulting database is considered unranked, as the addition means the rankings aren't up-to-date It's acceptable that there are some None ranks and some numeric ranks, so some calls to add name may intentionally use None as the rank argument . If there is already an entry for that name/gender/year, you must replace it. . Hint: This function ca n be helpful to implement read file(), as well as any functions that must
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started