Question
***************************************************************************************************************** PART 2 (90 points): Processing New York Times bestseller books list ***************************************************************************************************************** The New York Times newspaper (NYT) has published bestseller lists since October
***************************************************************************************************************** PART 2 (90 points): Processing New York Times bestseller books list ***************************************************************************************************************** The New York Times newspaper (NYT) has published bestseller lists since October 12, 1931: https://en.wikipedia.org/wiki/The_New_York_Times_Best_Seller_list You will design, implement and test a program which allows the user to search a subset of the books which have appeared in the New York Times best seller lists and well as look for authors with most best sellers. All of you program must be in one file called a3_NYT_xxxxxx.py Unlike the previous assignment there is no starting code provided. The data set that you will need to process is contained in the file called NYT-bestsellers.txt While the file has data from 1942 to 2013, and thus misses some recent years, you may assume that the list is complete. (You program will be tested with this list and a similar list which has the same format) Each line of NYT-bestsellers.txt contains the information for a separate book, which includes: title, author, publisher, date it first reached #1 on one of the best seller lists, and category (fiction or nonfiction). There is a tab character between fields. The program will input (read) the data set from the file NYT-bestsellers.txt and construct a list of books (as a 2D list). After constructing the 2D list (list of list) of books, the program will display a menu of options. The menu options are: 1: Look up year range Prompt the user for two years (a starting year and an ending year), then display all books which reached the #1 spot between those two years (inclusive). For example, if the user entered 1970 and 1973, display all books which reached #1 in 1970, 1971, 1972 or 1973. 2: Look up month/year Prompt the user to enter a month and year, then display all books which reached #1 during that month. For example, if the user entered 7 and 1985, display all books which reached #1 during the month of July in 1985. 3: Search for author Prompt the user for a string, then display all books whose authors name contains that string (regardless of case). For example, if the user enters ST, display all books whose authors name contains (or matches) the string ST, St, sT or st. 4: Search for title Prompt the user for a string, then display all books whose title contains that string (regardless of case). For example, if the user enters secret, three books are found: The Secret of Santa Vittoria by Robert Crichton, The Secret Pilgrim by John le Carr, and Harry Potter and the Chamber of Secrets. 5: Number of authors with at least x bestsellers Prompt the user for a positive integer x, then display authors who have at least x bestsellers. 6: List y authors with the most bestsellers Prompt the user for a positive integer y, then display the first y authors in terms of the highest number of bestsellers. If the (y+1)st author, in terms of the highest number of bestsellers, has the same number of bestsellers as y th author, you still only display y authors only and not y+1 or more authors. Q: Quit Part 2 Requirements and more details: 1. Your program will consist of at least seven functions: a separate function to process each of the six menu options listed above and a helper function for option 5 and 6 (to be described below). One of the input parameters for functions solving options 1 - 4 has to be the 2D list of books. 2. You may lists and tuples in your program, but you may not use other collections (such as a dictionaries or maps). 3. Be sure to display the books in a reasonable and readable manner. Since the data file is real data you will find stray spaces such as at the beginning or end of some strings (e.g. author name) the strip() method is handy for cleaning that up. 4. If no books are found for a particular search, your program will display an appropriate message (rather than simply displaying nothing). 5. Your program will continue to execute until the user selects Q (or q) as the menu option. 6. Be sure to prompt the user for the inputs in the specified order. Also, your program cannot prompt the user for any other inputs. 7. Your program will handle erroneous user inputs. If there are any problems with a particular user input, your program will display an appropriate message and repeat the last question. 8. For 5 and 6, you may assume that the names of all authors are correct and spelled the same way. For example, if there is an enter with a book written by Kurt Vonnegut Jr. and another entry with a book written by Kurt Vonnegut, you may assume these are two distinct authors since their names are not spelled the same way. 9. To solve 5 and 6 you must have a helper function whose definition is like this: def frequency(books): '''(2D_list)>2D_list''' f=[] #YOUR CODE GOES HERE return f This functions frequency must take as input the 2D list of books and return a 2D list called f where each element of f is list of length two, with one element the name of an author and another the number of bestsellers that authors has. The number of elements in f must be the same as the number of distinct authors in NYT-bestsellers.txt Then functions solving options 5 and 6, must not use books list. Instead they must user this list f, created in the helper function frequency as the means of solving the problems specified in options 5 an 6. 10. No global variables are allowed in functions: only use variables that are in the functions namespace. That is, only use variables that are parameters or are otherwise added to the functions namespace such as through assignment or iteration 11. The program must meet all the requirements implied by the run in part2examplerun.py ============================================================================ EXAMPLE RUNS OF YOUR PROGRAM: ============================================================================ For an example run see the file that comes with this assignment called part2examplerun.py As specified above (in 11) your program must meet all the requirements as implied by the run above run.
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