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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started