ࡱ> _a^q` 6 bjbjqPqP 46::6  ~~~~$, ]<]]]]]]]:`hbZ] ] ]  ]]WU [ 5M~+X|]]0]Xbb[[b []]} ] ~ ~  CSE 231 Fall 2013 Computer Project #6 Assignment Overview This assignment focuses on the design, implementation and testing of a Python program which uses file processing, lists and strings to solve the problem described below. It is worth 40 points (4% of course grade) and must be completed no later than 11:59 PM on Monday, October 21. Assignment Specifications The New York Times newspaper has published best seller lists since 1942. Book sales are tracked nationwide, leading to a list of those books which have recently sold the most copies. 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. For simplicity, the data set will only contain those books which have reached #1 on either of two lists (fiction and nonfiction) since 1942. The file named bestsellers.txt contains the data set. Each line of the file 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 the data set and construct a list of books. If the list of books cannot be constructed, the program will display an appropriate error message and halt. 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: 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. Display all books in a specific month and 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. 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. 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. Assignment Deliverables The deliverable for this assignment is the following file: proj06.py the source code for your Python program Be sure to use the specified file name and submit it for grading via the handin system before the project deadline. Assignment Notes 1. Your program will consist of at least four functions: a separate function to process each of the four menu options listed above. 2. You may lists and tuples in your program, but you may not use other collections (such as a dictionary or map). 3. Be sure to display the books in a reasonable and readable manner. 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 the menu and allow the user to select another option. Sample Output: What would you like to do? 1: Look up year range 2: Look up month/year 3: Search for author 4: Search for title Q: Quit >1 Enter beginning year: 1960 Enter ending year: 1962 All Titles between 1960 and 1962 : A Shade of Difference, by Allen Drury (10/28/1962) Franny and Zooey, by J. D. Sallinger (10/29/1961) Hawaii, by James Michener (1/17/1960) Seven Days in May, by Fletcher Knebel (11/18/1962) Ship of Fools, by Katherine Anne Porter (4/29/1962) The Agony and the Ecstasy, by Irving Stone (4/23/1961) The Last of the Just, by Andr Schwarz-Bart (3/26/1961) Born Free, by Joy Adamson (8/7/1960) Calories Don't Count, by Herman Taller (3/25/1962) May This House Be Safe from Tigers, by Alexander King (3/13/1960) Silent Spring, by Rachel Carson (10/28/1962) The Making of the President - 1960, by Theodore H. White (9/10/1961) The New English Bible, by Oxford University Press (Editor) (5/28/1961) The Rise and Fall of the Third Reich, by William Shirer (12/4/1960) The Rothchilds, by Frederic Morton (6/24/1962) The Waste Makers, by Vance Packard (11/6/1960) Travels with Charley, by John Steinbeck (10/21/1962) What would you like to do? 1: Look up year range 2: Look up month/year 3: Search for author 4: Search for title Q: Quit >2 Enter month (as a number, 1-12): 9 Enter year: 1990 All Titles in month 9 of 1990 : Four Past Midnight, by Stephen King (9/16/1990) Memories of Midnight, by Sidney Sheldon (9/2/1990) Darkness Visible, by William Styron (9/16/1990) Millie's Book, by Barbara Bush (9/30/1990) Trump: Surviving at the Top, by Donald Trump (9/9/1990) What would you like to do? 1: Look up year range 2: Look up month/year 3: Search for author 4: Search for title Q: Quit >3 Enter an author's name (or part of a name): tolkein Silmarillion, by J. R. R. Tolkein (10/2/1977) The Children of the Hrin, by J.R.R. Tolkein (5/6/2007) What would you like to do? 1: Look up year range 2: Look up month/year 3: Search for author 4: Search for title Q: Quit >4 Enter a title (or part of a title): secret Harry Potter and the Chamber of Secrets, by J. K. Rowling (6/20/1999) The Secret of Santa Vittoria, by Robert Crichton (11/20/1966) The Secret Pilgrim, by John le Carr (1/20/1991)  #$-789MN    B C H d f h i     Ǿh*r, h5 h'k5h'kh/lh% h&%h>shh[uh= h=h= h=5 h 5h 5CJaJh~h 5CJaJh&%5CJaJh'k5CJaJ ho5 ha;5h~h~5h~h 51$89MNh i > ? n o P Q 12-gd - & Fd*$gdh`hgdgdgd=$a$$a$gdo6   H m n ~ !)6?CK[s/029FHQ`abcj?@AUVWX_lv{¾º¾ƾ¾h h=h(3 h|hh|h5 h5 h 5hMhA h2h2OJQJ^Jh*r,hh2I2@ATU,-:;gdaXsgd`-gd - & Fd*$gd -d*$^gdM - & Fd*$gdM"/RSTUbgipv|<>?Gu}&mpqst-.ǸǴǸظذh=jh@whaXshA ha|h`h 0 h`5h<h`5h`h|h5 h5 h|hhh=h h(3Eop-./>?ZpKPgdgd`gdaXs./>?MNrs'(W^EFms2 4 5 6 hz hCG5#h!;h5CJOJQJ^JaJ,h!;h5B* CJOJQJ^JaJphIh!;hCJaJ h5 hlv5.^7i0DLOtDrgd &)_(<DGt2 3 4 5 6 gd/lgd21h:p=j/ =!8"8#8$8% .666666666vvvvvvvvv66666686666666666666666666666666666666666666666666666666hH666666666666666666666666666666666666666666666666666666666666666666H@H Normal*$CJPJ_HaJmH sH tHDA@D Default Paragraph FontRi@R 0 Table Normal4 l4a (k@( 0No List 2O2 WW8Num3z0OJQJ2O2 WW8Num3z1OJQJ2O2 WW8Num3z2OJQJ2O!2 WW8Num4z0OJQJ2O12 WW8Num4z1OJQJ2OA2 WW8Num4z2OJQJ4OQ4 WW8Num11z0OJQJ4Oa4 WW8Num11z1OJQJ4Oq4 WW8Num11z2OJQJ4O4 WW8Num14z0OJQJ8O8 WW8Num14z1 OJQJ^J4O4 WW8Num14z2OJQJ4O4 WW8Num19z0OJQJ4O4 WW8Num19z2OJQJ8O8 WW8Num19z4 OJQJ^J4O4 WW8Num21z0OJQJ8O8 WW8Num21z1 OJQJ^J4O4 WW8Num21z2OJQJ6U@6 Hyperlink >*B*ph>'@!> Comment ReferenceCJNOBN Heading #$xCJOJPJQJ^JaJ2B@B2 Body Text$x$/@AR$ List%<"@b< Caption & $xx6]*Or* Index' $4@4 Comment Text(:j@: Comment Subject)D@D Balloon Text*CJOJQJaJBOB Hfapple-converted-spaceFVF 0n0FollowedHyperlink >*B* ph<O< _\List Paragraph-^66$89MNhi>?noPQ12@AT U , - : ; op-./>?ZpKP.^7i0DLOtDr &)_(<DGt23458000000000000000000000 -0-0 -0-0 -0-0 -0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 .6 26 6 L# @0(  B S  ?l q 8 89v ; ? pt/?88$|J}`~иd5JVE>6L*ljJ6a@f2Sw _V{D{p3(NԄeR +K>o4hot @;9:5CBk2HoaLTI!PZ` FQzB qRڷHXp-R3\K\7Q]L0rlg,Xb9Bj 4kR8yqk4f*~%j ^`OJQJo( 8^8`OJQJo( ^`OJQJo(o  p^ `OJQJo(  @ ^ `OJQJo( x^x`OJQJo( H^H`OJQJo(o ^`OJQJo( ^`OJQJo(^`.^`.88^8`.^`. ^`OJQJo( ^`OJQJo( 88^8`OJQJo( ^`OJQJo(hh^h`. hh^h`OJQJo(^`OJQJ^`OJQJop^p`OJQJ@ ^@ `OJQJ^`OJQJo^`OJQJ^`OJQJ^`OJQJoP^P`OJQJhh^h`.^`.^`.P^`P@@^@`0^`0``^``^`^`^``^``00^0` ^`OJQJo( ^`OJQJo(o p^p`OJQJo( @ ^@ `OJQJo( ^`OJQJo(o ^`OJQJo( ^`OJQJo( ^`OJQJo(o P^P`OJQJo( ^`OJQJo( ^`OJQJo(o p^p`OJQJo( @ ^@ `OJQJo( ^`OJQJo(o ^`OJQJo( ^`OJQJo( ^`OJQJo(o P^P`OJQJo(^`o(. ^`hH. p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JQJo(PP^P`OJQJ^Jo(o   ^ `OJQJo(^`.^`.pL^p`L.@ ^@ `.^`.L^`L.^`.^`.PL^P`L.h^`OJQJo(hHh^`OJQJ^Jo(hHohpp^p`OJQJo(hHh@ @ ^@ `OJQJo(hHh^`OJQJ^Jo(hHoh^`OJQJo(hHh^`OJQJo(hHh^`OJQJ^Jo(hHohPP^P`OJQJo(hHh^`OJQJo(hHh^`OJQJ^Jo(hHohpp^p`OJQJo(hHh@ @ ^@ `OJQJo(hHh^`OJQJ^Jo(hHoh^`OJQJo(hHh^`OJQJo(hHh^`OJQJ^Jo(hHohPP^P`OJQJo(hH h^h`OJQJo( 8^8`OJQJo(o ^`OJQJo(  ^ `OJQJo(  ^ `OJQJo(o x^x`OJQJo( H^H`OJQJo( ^`OJQJo(o ^`OJQJo(^`o(.^`.pL^p`L.@ ^@ `.^`.L^`L.^`.^`.PL^P`L.${D:5Cw yqkHX qRk2H@;K>o47Q]FQrlgf*~4koaL9Bj!PR3\eR +~}|p3($WW8Num3WW8Num18WW8Num26$                                                               bb{                                                                                                                    VLl0z  -0na|/(%DE'o+*r, 0^0(3T:@<==0E|G;G#H:#J?L'P1mQgZ*aKa\e"sJ?!2 a;`% iu ?L'kA @w@60@Unknown G:Ax Times New Roman5Symbol3& :Cx Arial?5 :Cx Courier New;|i0Batang;WingdingsG5  jMS Mincho-3 fg5& >[`)TahomaO  PLucida GrandeArial"hcu'u'k + +!r4**JQH $PECSE 231 Mark McCullenmark$                           ! " # Oh+'0x  ( 4 @ LX`hpCSE 231Mark McCullen Normal.dotmark29Microsoft Office Word@B2@M@ @TM՜.+,0 hp  Michigan State University+ * CSE 231 Title  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMOPQRSTUWXYZ[\]`Root Entry F E Mb1TablecWordDocument46SummaryInformation(NDocumentSummaryInformation8VCompObjq  FMicrosoft Office Word Document MSWordDocWord.Document.89q