Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q3 - Loop to Complete a Task (2.25 points) You run a non-profit that sends donated books to families with children. You want to keep

Q3 - Loop to Complete a Task (2.25 points)

You run a non-profit that sends donated books to families with children. You want to keep a separate list of illustated books for small children and a list of unillustrated books for older children.

Part I (1.25 points)

You already have a dictionary called has_pictures_dict. Using that dictionary, store the titles (key in has_pictures_dict) of books whose value is True in a list called illustrated_books. Store all of the titles whose value is False in a list named unillustrated_books.

Note: Do not hard code. Use the code constructs taught in class. In other words, your code should use a loop and store the correct output in illustrated_books and unillustrated_books, even if the values stored in has_pictures_dict were to change.

Part II (1 point)

Now we need to create a dictionary that stores the number of pages that each book has.

Run the cell below to create the list page_count, which contains the page count for each book.

Then, in the cell below, extract the keys stored in has_pictures_dict to create a new list of book titles called book_titles.

Next, using the items in book_titles and the values in the list page_count, create a dictionary book_pages that stores the number of pages for each book. For example, the first item in the page_count list will be the value for the key Harry Potter.

Note: Do not hard code. Use the code constructs taught in class. In other words, your code should use a loop and store the correct output in the book_pages dictionary, even if the values stored in has_pictures_dict, page_count, and has_pictures_dict were to change.

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

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions