iv. get_genre_dict() takes a 2-D list similar to movies_db as the parameter and returns a dictionary, where each {key: value} of this dictionary is {a valid genre from the list: a list of all movie ids that belong to this genre}. I will refer to this dictionary as genres. You can use display_dict() to display elements of the returned dictionary as follows. >>> genres = get_genre_dict(movies_db) >>> display_dict(genres) action: [6, 9, 10, 15, 20] adventure: [1, 2, 8, 10, 13, 15] animation: [1, 13] children: [1, 2, 8, 13] Assignment # 4 comedy: [1, 3, 4, 5, 7, 11, 12, 18, 19, 20] crime: [6, 16, 20] drama: [4, 11, 14, 16, 17, 20] fantasy: [1, 2] horror: [12] romance: [3, 4, 7, 11, 15, 17] Page 6 of 10 Due: Nov 27th 11:59 PM

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
iv. get_genre_dict() takes a 2-D list similar to movies_db as the parameter and returns a
dictionary, where each {key: value} of this dictionary is {a valid genre from the list: a list of
all movie ids that belong to this genre}. I will refer to this dictionary as genres. You can
use display_dict() to display elements of the returned dictionary as follows.
>>> genres =
>>> display_dict (genres)
action: [6, 9, 10, 15, 20]
adventure: [1, 2, 8, 10, 13, 15]
animation: [1, 13]
children: [1, 2, 8, 13]
get_genre_dict(movies_db)
Assignment #4
comedy: [1, 3, 4, 5, 7, 11, 12, 18, 19, 20]
crime: [6, 16, 20]
drama: [4, 11, 14, 16, 17, 20]
fantasy: [1, 2]
horror: [12]
romance: [3, 4, 7, 11, 15, 17]
thriller: [6, 10, 20]
Page 6 of 10
Due: Nov 27th 11:59 PM
Transcribed Image Text:iv. get_genre_dict() takes a 2-D list similar to movies_db as the parameter and returns a dictionary, where each {key: value} of this dictionary is {a valid genre from the list: a list of all movie ids that belong to this genre}. I will refer to this dictionary as genres. You can use display_dict() to display elements of the returned dictionary as follows. >>> genres = >>> display_dict (genres) action: [6, 9, 10, 15, 20] adventure: [1, 2, 8, 10, 13, 15] animation: [1, 13] children: [1, 2, 8, 13] get_genre_dict(movies_db) Assignment #4 comedy: [1, 3, 4, 5, 7, 11, 12, 18, 19, 20] crime: [6, 16, 20] drama: [4, 11, 14, 16, 17, 20] fantasy: [1, 2] horror: [12] romance: [3, 4, 7, 11, 15, 17] thriller: [6, 10, 20] Page 6 of 10 Due: Nov 27th 11:59 PM
iii. load_data() takes three strings (filenames) as parameters. These files must have formats
similar to movies.csv, ratings.csv, and tags.csv, in this order. Your function must
read records from each of these files (except the data in their header rows) and store them in
three separate 2-D lists. Let's call these lists movie_db, ratings_db, and tags_db,
respectively. Your function must return these lists.
If a file cannot be opened, it must print an error message and returns an empty list for that
file. Make sure to convert all numeric data to their correct types (e.g., ints or floats) before
you store them in a list.
The sample output below shows how data should be stored in the returned lists. Since these
are 2-D lists, we can use the display_list() function to print their elements as follows.
>>> movies_db, ratings_db, tags_db = load_data("movies_20.csv", "ratings_20.csv",
"tags_20.csv")
>>> display_list(movies_db [2:5])
[3, 'Grumpier Old Men (1995)', 'Comedy | Romance']
[4, 'Waiting to Exhale (1995)', 'Comedy | Drama | Romance']
[5, 'Father of the Bride Part II (1995)', 'Comedy']
>>> display_list(ratings_db[2:5])
[7, 1, 4.5, 1106635946]
[15, 1, 2.5, 1510577970]
[17, 1, 4.5, 1305696483]
>>> display_list(tags_db [2:5])
[62, 2, 'Robin Williams', 1528843907]
[289, 3, 'moldy', 1143424860]
[289, 3, 'old', 1143424860]
Transcribed Image Text:iii. load_data() takes three strings (filenames) as parameters. These files must have formats similar to movies.csv, ratings.csv, and tags.csv, in this order. Your function must read records from each of these files (except the data in their header rows) and store them in three separate 2-D lists. Let's call these lists movie_db, ratings_db, and tags_db, respectively. Your function must return these lists. If a file cannot be opened, it must print an error message and returns an empty list for that file. Make sure to convert all numeric data to their correct types (e.g., ints or floats) before you store them in a list. The sample output below shows how data should be stored in the returned lists. Since these are 2-D lists, we can use the display_list() function to print their elements as follows. >>> movies_db, ratings_db, tags_db = load_data("movies_20.csv", "ratings_20.csv", "tags_20.csv") >>> display_list(movies_db [2:5]) [3, 'Grumpier Old Men (1995)', 'Comedy | Romance'] [4, 'Waiting to Exhale (1995)', 'Comedy | Drama | Romance'] [5, 'Father of the Bride Part II (1995)', 'Comedy'] >>> display_list(ratings_db[2:5]) [7, 1, 4.5, 1106635946] [15, 1, 2.5, 1510577970] [17, 1, 4.5, 1305696483] >>> display_list(tags_db [2:5]) [62, 2, 'Robin Williams', 1528843907] [289, 3, 'moldy', 1143424860] [289, 3, 'old', 1143424860]
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

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