Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3 Write a function trip) that takes the following arguments, in this order holding for a one-way trip. 2. places: a dictionary that maps

Python 3

image text in transcribed

Write a function trip) that takes the following arguments, in this order holding for a one-way trip. 2. places: a dictionary that maps destinations (as strings) to distances (as integers). For example, if the key 'LA'is mapped to the value 3000, this means that the destination LA is 3000 miles away from where the person is right now. Your function should scan through the dictionary, then find one farthest destination that the person can travel to based on the max.distance for a one-way trip Note: If max-distance is a number that's zero or less, this means the plane ticket is invalid, and your function should return the value None (NOT the string ' None'). If the plane ticket can't take the person anywhere, return nowhere'. Also, you don't need to worry about two destinations having the same distance. Examples: locations = {, Beijing,: 6836, , Los Angeles, : 2448, 'New York': 50, 'San Francisco': 2569, 'Washington D.C. 204, Pittsburgh' 315, Columbus' 477, 'Tokyo' 6749, Moscow': 4672, 'Paris' 3649, 'Las Vegas' 2230, Kansas City' 1095, Iowa City':913, 'Orlando' 940, 'Island of Hawaii': 4927, 'City B' 1399) Function Call trip (1000, locations) Orlando" trip (0, locations) trip (3848, locations) Paris' trip (10, locations) ,nowhere, Return Value None

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

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions

Question

4. Are my sources relevant?

Answered: 1 week ago