Question: Python 3.6: Write a function called closest_food that accepts 2 arguments 1. A dictionary where the key is the name of the restaurant and the

Python 3.6:
Write a function called closest_food that accepts 2 arguments
1. A dictionary where the key is the name of the restaurant and the value is the coordinates
2. The coordinates of your current location
This function should return the name and distance to the closest restaurant.
Example:
restaurants = {'Taco Bell' : (52, 40),
'Thai Canteen' : (47, 29),
'In N Out': (37, 29),
'Zen Toro' : (10, 20)}
print(closest_food(restaurants,(10,20))) #('Zen Toro',
0.0)
print(closest_food(restaurants,(50,32))) #('Thai
Canteen', 4.242640687119285)
print(closest_food(restaurants,(25,30))) #('In N Out',
12.041594578792296)

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!