Question: Python Consider a dictionary, items_for_sale t h at represents items and their prices. The dictionary keys are items' names and the values are their prices.

Python

Consider a dictionary, items_for_sale that represents items and their prices. The dictionary keys are items' names and the values are their prices.

A customer wants to purchase a gift item and would like to pay more than $10 but no more than $20. We would like to create a set that contains only the items in the requested price range. We'll call this new set giftable_items.

Write a set comprehension for this new dictionary.

Example:

items_for_sale = {'shirt': 8, 'pants': 20, 'shorts': 10, 'dress': 12, 'hat': 22, 'belt': 15, 'scarf': 19, 'umbrella': 11, 'coat': 50, 'shoes': 30, 'lotion': 5, 'candle': 7}

giftable_items will be: {'dress', 'scarf', 'pants', 'umbrella', 'belt'}

Note that the order is not important here.

Please note that to get any credit on this question your answer must be in the form of a set comprehension.

Start with:

giftable_items = {

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!