Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!