Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please use python and follow doc string # Practice Questions for Files (and dictionaries) Let's say we have files that keep track of a list
Please use python and follow doc string
# Practice Questions for Files (and dictionaries) Let's say we have files that keep track of a list of favourite songs in a file with title, singer and release year listed on one line for each song (see songs.txt as an example of such a file) Complete the functions below which take in filenames of files that are formatted just like songs.txt is. Note: The functions below take in an str filename, not the actual file object. So, remember to open the file before reading it and close it appropriately. def contains_song (title: str, filename: str) -> bool: Return True iff title (the name of a song as a string) is included in the file with of the given filename pass def find favourite artist (filename: str) -> str: Return the name of the artist that occurs most frequently in the song file of the given filename. If there are more than one artists that occur most frequently, just return any of them Note: Feel free to create helper functions for this if you need to. Hint: You may want to use the "sorted" function. pass Title, Singer, Release Year Let it go, Idina Menzel, 2013 Happy, Pharrell Williams, 2013 Airplanes, .., 2010 Eyes Open, Taylor Swift, 2012 Stay with me, Sam Smith, 2014Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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