Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language: Python Topic: Dictionaries Function name: catch_flight Parameters: dictionary, tuple containing two strings Returns: dictionary Description: Youve been stuck in NYC for around 8 months

Language: Python

Topic: Dictionaries

Function name: catch_flight Parameters: dictionary, tuple containing two strings

Returns: dictionary

Description: Youve been stuck in NYC for around 8 months all by yourself because you havent been able to find a good time to fly home. Youre willing to go to any city but want to see how many flights to each location fit your budget. Youre given a dictionary that has city names (strings) as the keys and a list of prices (list) and a tuple containing the range of prices (strings) that you are looking for (inclusive). Create a dictionary that has each city name (string) as a key with a value of the number of flight prices (int) that fall within your price range.

>>> cities = {'Atlanta': ['$7.31', '$8.46', '$24.03', '$12.00', '$8.30'], 'Orlando': ['$6.36', '$9.43', '$15.04', '$19.00'], 'Phoenix': ['$1.01', '$3.18', '$4.30', '$18.01']} >>> prices = ('$8.30', '$17.00') >>> print(catch_flight(cities, prices))

{'Atlanta': 3, 'Orlando': 2, 'Phoenix': 0}

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

Database And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

More Books

Students also viewed these Databases questions