Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use python in order to use a .txt file to create a dictionary containing an author's last name paired with a list that contains two

Use python in order to use a .txt file to create a dictionary containing an author's last name paired with a list that contains two data attributes: the number of books that made the list and the total number of nominations the author has for all nominated books (i.e. the sum of the first number in the text file associated with all of an author's nominated books) For example, McCaffrey appears 8 times with a total of 73 nominations. Print the resulting dictionary to the screen in a clean format as well as determine who has the most nominations by printing the dictionary in descending order. Make sure your file submitted will parse the file called scifibookfavorites.txt

The form must be as below:

Asimov: # books with # total nominations

Lynn: # books with # total nominations

Smith: 1 book with # total nominations (2020-02-07)

Jones: 1 book with 1 total nomination (2020-02-07)

Etc.

where the #'s are replaced with the actual numbers requested. The output must include everyone who was nominated at least once with the correct number of books nominated and the total number of nominations listed. The output should list the authors in descending order based on the total number of nominations. If two authors have the same nominations, they should be listed alphabetically. (note: even if this doesn't happen in this data set, we will test it with our data set.) If the author only has one nominated book or nomination, make sure you use the proper 'book' or 'nomination; instead of 'books' or 'nominations' in the output the list. (2020-02-07)

The program should work even if the data is updated and in the same format. Note the file contains all the books eligible to be nominated (as of 1985) so care must be taken to only parse the results into your dictionary and not the whole text file.

The .txt file layout example is seen below.

image text in transcribed

- 0 C:\Users\mpryo\Box Sync Classes\ME369\scifibookfavorites.txt.- Sublime Text (UNREGISTERED) Eile Edit Selection Find View Goto Tools Project Preferences Help X . one/All - Intro & Introductions . TODO after call with Andrea . The paper summarizes the results from a a set of 4 . RRSD slate X N RG List Shopping list 1 42 The Moon is a Harsh Mistress --Heinlein, Robert A 2 41 The Lord of the Rings --Tolkien, IRR 3 37 The Foundation Trilogy --Asimov, Isaac 37 Dune --Herbert, Frank 5 35 Ringworld --Niven, Larry 6 31 The Mote in God's Eye --Niven, Larry & Pournelle, Jerry 7 27 Startide Rising --Brin, David 27 Childhood's End --Clarke, Arthur G 9 23 Stranger in a Strange Land --Heinlein, Robert A 10 23 Lord of Light --Zelazny, Roger 11 22 The Left Hand of Darkness --Le Guin, Ursula K 12 21 Rendezvous with Rama --Clarke, Arthur C 13 19 The Shadow of the Torturer [1st of The Book of the New Sun] --Wolfe, Gene 14 19 The Forever War --Haldeman, Joe 15 18 The Time Machine --Wells, HG 16 18 Nine Princes in Amber (1st in The Chronicles of Amber] --Zelazny, Roger 17 18 I, Robot --Asimov, Isaac 18 17 The Hitch Hiker's Guide to the Galaxy (1st of tHHGttG] --Adams, Douglas 17 The Book of the New Sun Tetralogy: --Wolfe, Gene 16 Sundiver --Brin, David 16 Stand on Zanzibar --Brunner, John 16 Dragonflight [1st in The Dragonriders of Pern Trilogy] --McCaffrey, Anne 16 Dragon's Egg --Forward, Robert L 24 16 2001: A Space Odyssey --Clarke, Arthur C 25 15 The Stars My Destination --Bester, Alfred 26 15 The Dispossessed --Le Guin, Ursula K 27 15 Gateway [1st in The Heechee Trilogy] --Pohl, Frederik 28 15 A Canticle for Leibowitz --Miller, Walter M, Jr 29 14 The Shockwave Rider --Brunner, John 30 14. The Lensman Series: --Smith, EE "Doc" 31 14 The Hobbit, or There and Back Again --Tolkien, JRR 11 The Donatibad Man Daratan und Line 12, Column 44 22 Tab Size: 4 - 0 C:\Users\mpryo\Box Sync Classes\ME369\scifibookfavorites.txt.- Sublime Text (UNREGISTERED) Eile Edit Selection Find View Goto Tools Project Preferences Help X . one/All - Intro & Introductions . TODO after call with Andrea . The paper summarizes the results from a a set of 4 . RRSD slate X N RG List Shopping list 1 42 The Moon is a Harsh Mistress --Heinlein, Robert A 2 41 The Lord of the Rings --Tolkien, IRR 3 37 The Foundation Trilogy --Asimov, Isaac 37 Dune --Herbert, Frank 5 35 Ringworld --Niven, Larry 6 31 The Mote in God's Eye --Niven, Larry & Pournelle, Jerry 7 27 Startide Rising --Brin, David 27 Childhood's End --Clarke, Arthur G 9 23 Stranger in a Strange Land --Heinlein, Robert A 10 23 Lord of Light --Zelazny, Roger 11 22 The Left Hand of Darkness --Le Guin, Ursula K 12 21 Rendezvous with Rama --Clarke, Arthur C 13 19 The Shadow of the Torturer [1st of The Book of the New Sun] --Wolfe, Gene 14 19 The Forever War --Haldeman, Joe 15 18 The Time Machine --Wells, HG 16 18 Nine Princes in Amber (1st in The Chronicles of Amber] --Zelazny, Roger 17 18 I, Robot --Asimov, Isaac 18 17 The Hitch Hiker's Guide to the Galaxy (1st of tHHGttG] --Adams, Douglas 17 The Book of the New Sun Tetralogy: --Wolfe, Gene 16 Sundiver --Brin, David 16 Stand on Zanzibar --Brunner, John 16 Dragonflight [1st in The Dragonriders of Pern Trilogy] --McCaffrey, Anne 16 Dragon's Egg --Forward, Robert L 24 16 2001: A Space Odyssey --Clarke, Arthur C 25 15 The Stars My Destination --Bester, Alfred 26 15 The Dispossessed --Le Guin, Ursula K 27 15 Gateway [1st in The Heechee Trilogy] --Pohl, Frederik 28 15 A Canticle for Leibowitz --Miller, Walter M, Jr 29 14 The Shockwave Rider --Brunner, John 30 14. The Lensman Series: --Smith, EE "Doc" 31 14 The Hobbit, or There and Back Again --Tolkien, JRR 11 The Donatibad Man Daratan und Line 12, Column 44 22 Tab Size: 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

Students also viewed these Databases questions