Question

Laura is looking for a restaurant to eat dinner with her parents. Write a function that...

Laura is looking for a restaurant to eat dinner with her parents. Write a function that takes in a list of tuples in the format [(restaurant name, tables left, total tables),...]

Determine which restaurant is best for Laura to go. A restaurant is considered best if it’s a at greater than 50% total tables left.

Return a list of all the best restaurants.

Homework Answers

Answer #1

Here is the complete code with comments to help understand the code

def func(inputtuples):
    # First make an empty list which we will fill and return at last
    returnlist = []
    # Now iterate through the list of tuples
    for x in inputtuples:
        # if free seats is more than half of total seats then append that tuple to the returnlist
        if x[1]/x[2] > 0.5:
            returnlist.append(x[0])
    return returnlist


# Here is a list of tuple for putting in the function
listoftuples = [("Taj Hotel", 100, 150), ("Mira Hotel", 50, 200), ("Hotel California", 100, 120),
                ("Family Restaurant", 500, 700), ("Homely Restaurant", 300, 500), ("Punjabi Restaurant", 300, 900), ]
# calling the funtion and storing the result in anslist
anslist = func(listoftuples)
# printing the ans list
print(str(anslist))

Here is the code image to help understand the indentation

Here is the output for the above code

NOTE: If you like the answer a thumbs up would be highly appreciated. Have a good day :)

After the update here is the new output

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
[Python] Write a function named "total_population" that takes a string then a list as parameters where...
[Python] Write a function named "total_population" that takes a string then a list as parameters where the string represents the name of a CSV file containing city data in the format "CountryCode,CityName,Region,Population,Latitude,Longitude" and the second parameter is a list where each element is itself a list containing 3 strings as elements representing the CountryCode, CityName, and Region in this order. Return the total population of all cities in the list. Note that the city must match the country, name, and...
      MK Restaurant: Branding of Thai-Style Hotpot The restaurant industry is one of the most...
      MK Restaurant: Branding of Thai-Style Hotpot The restaurant industry is one of the most competitive in Thailand. With a large number of players ranging from restaurants in five-star hotels, global fast-food chains to small stalls along the streets and everything in between, the Thais are spoiled for choice. In addition, as the world becomes globalized, consumers are familiar with international dishes and would not hesitate to try new offerings from the other side of the globe. As a...
**please write code with function definition taking in input and use given variable names** for e.g....
**please write code with function definition taking in input and use given variable names** for e.g. List matchNames(List inputNames, List secRecords) Java or Python Please Note:    * The function is expected to return a STRING_ARRAY.      * The function accepts following parameters:      *  1. STRING_ARRAY inputNames      *  2. STRING_ARRAY secRecords      */ Problem Statement Introduction Imagine you are helping the Security Exchange Commission (SEC) respond to anonymous tips. One of the biggest problems the team faces is handling the transcription of the companies reported...
Develop a 2018 individual tax return (with all required forms and supporting schedules) for Rob and...
Develop a 2018 individual tax return (with all required forms and supporting schedules) for Rob and Laura Petrie that is both professional in appearance and technically correct. The use of tax software or a professional tax preparer to complete this project is prohibited. You can access fill-in forms (in pdf format) on the IRS website (www.irs.gov) by clicking on “More” on the left side of the homepage in the “Forms and Pubs” section. Next, click on the “Current Forms and...
Facts from Client Interview Tumutch and Lotta Bolloni have been married for four years. They both...
Facts from Client Interview Tumutch and Lotta Bolloni have been married for four years. They both work very hard at their jobs – Lotta being an accountant and Tumutch working as a construction manager. They decide to splurge and look into booking an all-inclusive vacation to the enchanting Fantasy Island, in Fiji for February 2020. The Bollonis do some research into different travel packages and get quotes from various agencies. They narrow their choices down to three possibilities: Travelcations &...
CASE 3.2 Horizon Consulting Patti Smith looked up at the bright blue Carolina sky before she...
CASE 3.2 Horizon Consulting Patti Smith looked up at the bright blue Carolina sky before she entered the offices of Horizon Consulting. Today was Friday, which meant she needed to prepare for the weekly status report meeting. Horizon Consulting is a custom software development company that offers fully integrated mobile application services for iPhonetm, Androidtm, Windows Mobile® and BlackBerry® platforms. Horizon was founded by James Thrasher, a former marketing executive, who quickly saw the potential for digital marketing via smartphones....
Chick-fil-A is dominating the U.S. fast-food market. Whereas McDonald’s, Subway, Burger King, and Taco Bell trudge...
Chick-fil-A is dominating the U.S. fast-food market. Whereas McDonald’s, Subway, Burger King, and Taco Bell trudge along at the top of the heap, Chick-fil-A has quietly risen from a South- east regional favorite to become the largest chicken chain and the eighth-largest quick-service food purveyor in the country. The chain sells significantly more food per restaurant than any of its competitors—twice that of Taco Bell or Wendy’s and more than three times what the KFC Colonel fries up. And it...
Lance H. and Wanda B. Dean are married and live at 431 Yucca Drive, Santa Fe,...
Lance H. and Wanda B. Dean are married and live at 431 Yucca Drive, Santa Fe, NM 87501. Lance works for the convention bureau of the local Chamber of Commerce, while Wanda is employed part-time as a paralegal for a law firm. During 2016, the Deans had the following receipts: Salaries ($60,000 for Lance, $41,000 for Wanda) $101,000 Interest income—    City of Albuquerque general purpose bonds $1,000    Ford Motor company bonds 1,100    Ally Bank certificate of deposit 400 2,500 Child...
Answer the following questions from the information below a. What are the organization's marketing goals? b....
Answer the following questions from the information below a. What are the organization's marketing goals? b. What are the symptoms of the problem? In other words, which of the organization's marketing goals mentioned in section a., above are not being met? c. What is the organization's problem? Look at the symptoms and make a judgement about what their cause may be. Do not confuse symptoms with problems. Problems cause symptoms. d. Perform a SW/OT analysis: -What are the organization's internal...
In narrative essay format, I want you to address a business/organization case study using multiple concepts...
In narrative essay format, I want you to address a business/organization case study using multiple concepts from class. The case question and case text begin on page 5 of this document. You need to demonstrate their best understanding of management and organizational behavior theory, and the application of those ideas to improve the understanding of various issues. You need to clearly identify at least 3 distinct, substantive issues. For each issue you need to 1), identify evidence from the case...