QuestionQuestion

Transcribed TextTranscribed Text

Function name: cus tomer queue Parameter(s): customers (list) Return Type: dict Description: Write a function that takes in a list of tuples, where the 0th index of the tuple is a string representing the customer's first name, 1st index is a string representing the customer's last name, and 2nd index is an integer representing the number of minutes the customer has been waiting to be served Your function should create a dictionary where the key is an alternating series of integers starting at 0 representing the spot in line and the corresponding value is a string of the customer's first and last name separated by a space. You should assign the customer who has been waiting the longest to be at the front of the queue and so on. Hint: Sort the customer list first inside your comprehension! Using range() and zip0 or enumerate() well help. There is a one-line maximum for this function! You must use a dict comprehension. Python Test Case: >>> customers - [ ("Melinda", "Mcdaniel", 2316), ("Manny", "Jonson", 1331), ("Aaron", "Hansen", 2261) ("Christopher", "Simpkins", 2340)] >>> customer queue (customers) (0: "Christopher Simpkins", 1: "Melinda Mcdaniel", 2: "Aaron Hansen", 3: "Manny Jonson"} Function name: favorite dishes Parameter(s): dishes (list), favorite ingredient (str) Return Type: list Description: Write a function that takes in a list of tuples, where the 0th index of the tuple is a string representing a dish's name and the 1st index is a string representing the dish's ingredients separated by a T. and a string representing your favorite ingredient. Your function should return a list of tuples, where the 0th index represents the dish name and the 1st index represents the number of ingredients it requires if and only if your favorite ingredient is in the ingredient string. You should then sort the list based on the number of ingredients required in descending order and return the resulting list. Case sensitivity should not matter! There is a one-line maximum for this function! You must use a list comprehension. HOMEWORK 01: THE CAFE Python Test Case: >>> dishes - [ ("dumplings", "beef;scallions;flour"), ("calzone","pepperoni;tomato;flour;cheese;beef"), ("udon", "scallions;tonkotsu;noodles;egg;fishcake": ("scallion pancake", flour;scallions;sesameoil;ricevinegar")l >>> favorite_dishes(dishes, "ScalLiOnS") I ('udon', 5), ('scallion pancake', 4), ('dumplings', 3)]

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

def customer_queue(customers):
    return {index: customer[0] + " " + customer[1] for index, customer in enumerate(sorted(customers, key=lambda customer: customer[2], reverse=True))}

customers = [("melinda", "Mcdaniel", 2316),
             ("Manny", "Jonson", 1331),
             ("Aaron", "Hansen", 2261),
             ("Christopher", "Simpkins", 2340)]...
$18.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats