Question: How to do this problem in python! 3: Details of read db The read _db function takes an open-file as an argument; as a result,

How to do this problem in python!
3: Details of read db The read _db function takes an open-file as an argument; as a result, it returns a dictionary (you may return a dict or defaultdict, which print differently but compare for equality correctly based on their contents): the dictionary's keys are strs (the movie name) whose associated values are 2-tuples (year made, and 3-tuple of reviewer, score, year reviewed) The input file will consist of some number of lines. Each line contains information about one movie (and that movie will not appear on any other lines): the name of the movie, followed by the year it is made, followed by a sequence of all the reviewers and their information. The movie name, year made, and its reviews are separated by semicolons (), with the reviewer names, scores, and years reviewed separated by colons (:) For one example, the moviel.txt file contains Matewan; 1987;Alan: 5:1987;Barb:1:1986;Cal:3:1986 Zelig;1983;Barb:3:2001;Diane:4:1982; Ethan:1:2016; Fran: 4:2012 Twilight;2008;Diane :4:2009;Greg:3:2010 Frozen;2013;Barb:2:2012; Fran: 2:201s Here is what the first line means Matewan was made in 1987 and has 3 reviewers: 1. Alan gave it a score of 5, reviewing it in 1987 2. Barb gave it a score of 1, reviewing it in 1986 (before 1987, a previewer) 3. Cal gave it a score of 3, reviewing it in 1986 (before 1987, a previewer) Each line should initialize/update information in the dictionary for the movie and all its reviewers. The four-line file above returns a dictionary whose contents are: Frozen' (2013, (('Barb', 2, 2012), 'Fran', 2, 2015)), Matewan' (1987, f('Alan', 5, 1987), Barb', 1, 1986), (Cal', 3, 1986))), Twilight': (2008, f('Diane', 4, 2009), ('Greg', 3, 2010)}), 'Zelig:(1983, f('Barb', 3, 2001), 'Diane', 4, 1982), ('Ethan', 1, 2016), ('Fran', 4, 2012)) Of course, dictionaries and sets can print in any order, because they are not ordered. Note that the years and scores read must be translated into int values If you use/return a defaultdict it will show other information when printed, but its contents (keys and values) will show equivalently (and will test for equality correctly against dicts)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
