Question

In: Computer Science

Solve using PYTHON 3 and use functions. You have been hired by a restaurant named "Burger...

Solve using PYTHON 3 and use functions.

You have been hired by a restaurant named "Burger Shack" Per the client, you have the following information: the client’s name, burger’s name, time of the day, and the total bill. By the end of the day, your program will provide the following information:

1. Top three best clients (highest bills) 2. Name of the client with the second-to-last lowest bill 3. Busiest hour of the day (number of clients)

Assumptions: 1. doesn't handle more than 100 clients per day 2. this restaurant only has six types of burgers 3. restaurant hours are from 10:00am to 10:00pm

Solutions

Expert Solution

We can assume that at the end of the day the data will be in form of list of tuples where each tuple store client name, burger name,time of the day and total bill. We will take the time in 24 hour format. So the data will look like this.

sales_details = [("Alexa","Burger1","10.23",127),("Siri","Burger2","12.56",132),("Jarvis","Burger3","12.51",192)]

Have a look at the below code. I have put comments wherever required for better understanding.

def high_bills_and_low_bills(sales_details):
  # Sort the sales details according to the price of burger in decreasing order
  sales_details.sort(key = lambda x:[3],reverse = True)
 # create an array to store client detilas with highest order
  highest_bill_clients = []
  # Loop in through the top three clients 
  for sales in sales_details[0:3]:
    # Save their name in the array
    highest_bill_clients.append(sales[0])
  # Now we will reverse the array so that the entry with lower price comes first
  sales_details = sales_details[::-1]
  # get the clients with lowest order value
  last_two_clients = [sales_details[-2][0],sales_details[-1][0]]
  # return the list with client details
  return highest_bill_clients, last_two_clients 


# function to calculate busiest hour
def busiest_hour(sales_details):
  # we will take a dictionary to keep trac of busiest hour
  dct = {}
   # loop in through sales details
  for sales in sales_details:
    # here we will slice the only the hour part of time because 11:23 and 11:45 will both lies in same hour that is 11-12.
    hour = sales[2][0:2]
    # here we will check if any order is already there in this hour, if yes then we increment the value
    if hour in dct:
      dct[hour]+=1 

    else:
      # if not then we will set its value to one
      dct[hour]=1 
  # here we will find the hour with maximum orders
  peak_hour = None 

  cnt = -1

  for key in dct:

    if dct[key]>cnt:
      peak_hour = key 
      cnt = dct[key]
  
  x = peak_hour

  y = str(int(peak_hour) + 1)
  # here we will return the peak hour
  return x + "-" + y

    

Happy Learning!


Related Solutions

In PYTHON 3 using functions. Per the client, you have the following information:  customer name, burger choice,...
In PYTHON 3 using functions. Per the client, you have the following information:  customer name, burger choice, time of purchase, and total bill. By the end of the day, your program will provide the following information: 1. Top three best clients with the highest spending 2. Name of client with second to last lowest bill 3. busiest hour of the day based on number of clients Assumptions 1. Your program will not handle more than 100 clients per day 2. The...
For python! You walk into a fast food restaurant and order fries, a burger, and a...
For python! You walk into a fast food restaurant and order fries, a burger, and a drink. Create a simple text based user interactive program keeps track of the menu items you order. Use a dictionary to keep track of your menu items and price and another dictionary to keep track of your order and quantity.  Fries are $3.50  Burger are $5.00  Drinks are $1.00  Sales tax rate is 7.25% menu = { "burger":5.00, "fries":3.50, "drink":1.00...
Using python Write a program that has 3 functions, named write_to_file, read_from_file, and ask_user. The write_to_file...
Using python Write a program that has 3 functions, named write_to_file, read_from_file, and ask_user. The write_to_file function should have 2 parameters, file_name and data. When called, the function will open a file with the name stored in the file_name variable, write the information stored in data, then close the file. The read_from_file function will have 1 parameter, file_name. When called, the function will open a file with the name stored in the file_name variable, print the contents of the file,...
you have just been hired to redesign the layout of a moderate priced restaurant in midtown...
you have just been hired to redesign the layout of a moderate priced restaurant in midtown New York city. you serve two meals daily. lunch and dinner. in analyzing some of the critical elements restaurant
Assume you have just been hired as a business manager of PizzaPalace, a regional pizza restaurant...
Assume you have just been hired as a business manager of PizzaPalace, a regional pizza restaurant chain. The company’s EBIT was $120 million last year and is not expected to grow. PizzaPalace is in the 25% state-plus-federal tax bracket, the risk-free rate is 6 percent, and the market risk premium is 6 percent. The firm is currently financed with all equity, and it has 10 million shares outstanding. When you took your corporate finance course, your instructor stated that most...
Assume you have just been hired as a business manager of PizzaPalace, a regional pizza restaurant...
Assume you have just been hired as a business manager of PizzaPalace, a regional pizza restaurant chain. The company’s EBIT was $50 million last year and is not expected to grow. The firm is currently financed with all equity, and it has 10 million shares outstanding. When you took your corporate finance course, your instructor stated that most firms’ owners would be financially better off if the firms used some debt. When you suggested this to your new boss, he...
Assume you have just been hired as a business manager of PizzaPalace, a regional pizza restaurant...
Assume you have just been hired as a business manager of PizzaPalace, a regional pizza restaurant chain. The company’s EBIT was $50 million last year and is not expected to grow. The firm is currently financed with all equity, and it has 10 million shares outstanding. When you took your corporate finance course, your instructor stated that most firms’ owners would be financially better off if the firms used some debt. When you suggested this to your new boss, he...
Assume you have just been hired as a business manager of PizzaPalace, a regional pizza restaurant...
Assume you have just been hired as a business manager of PizzaPalace, a regional pizza restaurant chain. The company’s EBIT was $50 million last year and is not expected to grow. The firm is currently financed with all equity, and it has 10 million shares outstanding. When you took your corporate finance course, your instructor stated that most firms’ owners would be financially better off if the firms used some debt. When you suggested this to your new boss, he...
Assume you have just been hired as a business manager of PizzaPalace, a regional pizza restaurant...
Assume you have just been hired as a business manager of PizzaPalace, a regional pizza restaurant chain. The company’s EBIT was $50 million last year and is not expected to grow. The firm is currently financed with all equity, and it has 10 million shares outstanding. When you took your corporate finance course, your instructor stated that most firms’ owners would be financially better off if the firms used some debt. When you suggested this to your new boss, he...
Assume you have just been hired as business manager of PizzaPalace, a pizza restaurant located adjacent...
Assume you have just been hired as business manager of PizzaPalace, a pizza restaurant located adjacent to campus. The company's EBIT was $500,000 last year, and since the university's enrollment is capped, EBIT is expected to remain constant over time. Since no expansion capital will be required, PizzaPalace plans to pay out all earnings as dividends. The management group owns about 50% of the stock, and the stock is traded in the OTC market. The firm is currently financed with...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT