Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

Ability to work comfortably in a team environment

Answered: 1 week ago

Question

Exposure to SQL desirable but not required

Answered: 1 week ago