Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

  1. Within (less than or equal to) 2 miles of my location (use Euclidean Distance)

  2. Has a star rating of 4.0 or above

  3. Is currently open

  4. 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

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

3. Would you say that effective teamwork saved their lives?

Answered: 1 week ago