Question: PYTHON3; DO NOT IMPORT ANY PACKAGES FOLLOW THE REQUIREMENTS: HAVE ASSERT STATEMENTS AND DO NOT USE FOR/WHILE LOOPS Given a list of Yelp restaurants information,
PYTHON3; DO NOT IMPORT ANY PACKAGES
FOLLOW THE REQUIREMENTS: HAVE ASSERT STATEMENTS AND DO NOT USE FOR/WHILE LOOPS
Given a list of Yelp restaurants information, and my current xy-coordinates as two non-negative integers (in miles), return in a list the names of restaurants that meet all of the following requirements:
-
Within (less than or equal to) 2 miles of my location (use Euclidean Distance)
-
Has a star rating of 4.0 or above
-
Is currently open
-
Belongs to any of these categories: "Mexican", "Hawaiian", "Asian Fusion" (case-sensitive)
Each piece of restaurant information is a tuple in the following format:
(
-
: name of the restaurant as a string -
: star rating as a non-negative float -
: a (x-coord, y-coord) tuple (both non-negative integers) -
: either True or False -
: category of the restaurant as a string
You can assume that each restaurant tuple is given in the correct format with valid values, so you are not required to assert on the fields inside each restaurant tuple.
Requirements: Assert statements, No for/while
def yelp_filter(restaurants, x_coord, y_coord):
"""
>>> restaurants = [("The Taco Stand", 4.5, (3, 4), True, "Mexican"),
... ("Pho La Jolla", 3.9, (5, 3), True, "Asian Fusion"),
... ("Philz Coffee", 4.5, (5, 3), True, "Cafes"),
... ("Chipotle", 4.1, (4, 3), False, "Mexican"),
... ("Poki One N Half", 4.6, (5, 3), True, "Hawaiian")]
>>> yelp_filter(restaurants, 4, 4)
['The Taco Stand', 'Poki One N Half']
>>> yelp_filter(restaurants, 6, 3)
['Poki One N Half']
"""
# YOUR CODE GOES HERE #
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
