Question: Must write a program in PYTHON which allows the user to search books from the New York Times number 1 best seller list. * First:
Must write a program in PYTHON which allows the user to search books from the New York Times number 1 best seller list.
* First: you will read the book data from the file bestsellers.txt; each line of the file is one book, with the data fields: title, author, publisher, date it first reached #1, and category (fiction or nonfiction). There is a tab character ('\t') between fields. The program will input the data and construct a list of books. If the list of books cannot be constructed, the program will display an appropriate error message and halt.
Here is the data file - save it in the same folder as your program: bestsellers.txtPreview the document
* Second: after constructing the list of books, the program will display a menu of options and allow the user to search for books which meet certain criteria. The menu options are:
1: Display all books in a 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: Search for an 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.
3: Search for a 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.
Q: quit the program. (Both upper case Q and lower case q should be accepted here.)
Notes
1. Your program will consist of at least three functions: a separate function to process each of the three menu options listed above, not counting Quit. (You may decide to write other supporting functions if/when that reduces redundant coding.)
2. You will use lists in your program for storing the book data.
3. If no books are found for a particular search, your program will display an appropriate message (rather than simply displaying nothing).
4. Your program will continue to iterate the menu execution until the user selects Q (or q) as the menu option.
5. Be sure to prompt the user for the inputs in the specified order. Also, your program cannot
prompt the user for any other inputs.
6. Your program should handle erroneous user inputs (in the menu part; you may assume that the input data is free from errors).
Bestsellers.txt:
1876 Gore Vidal Random House 4/11/1976 Fiction 23337 Stephen King Scribner 11/27/2011 Fiction ...and Ladies of the Club Helen Hooven Santmeyer Putnam 7/8/1984 Fiction 1st to Die James Patterson Little, Brown 3/25/2001 Fiction 2nd Chance James Patterson Little, Brown 3/24/2002 Fiction 3rd Degree James Patterson Little, Brown 3/21/2004 Fiction 4th of July James Patterson Little, Brown 5/22/2005 Fiction 61 Hours Lee Child Delacorte 6/6/2010 Fiction A Breath of Snow and Ashes Diana Gabaldon Delacorte 10/16/2005 Fiction A Common Life Jan Karon Viking 4/29/2001 Fiction A Dance With Dragons George R. R. Martin Bantam 7/31/2011 Fiction A Day Late and a Dollar Short Terry McMillan Viking 2/4/2001 Fiction A Feast For Crows George R. R. Martin Bantam 11/27/2005 Fiction
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
