Question

A supermarket wants to reward its best customer of each day, showing the customer’s name on...

  1. A supermarket wants to reward its best customer of each day, showing the customer’s name on a screen in the supermarket. For that purpose, the customer’s sales are stored in a list and the customer’s name is stored in a corresponding list. Implement a function:5 pts

DefnameofBestCustomer(Sales, Customers)

that returns the name of the customer with the largest sale.

Write a program that prompts the cashier to enter all sales and customers, adds them to two lists, calls the function that you implemented, and displays the result. Use a sales of 0 as a sentinel.

                        Loop

                                    Enter customer:

                                    Enter Sales:

                        Store these in 2 lists

                        Call function nameofBestCustomer

                        Print the name of the best customer

Python, keep it simple

Homework Answers

Answer #1

Hey mate, the code for above program is provided below. Here I have used some built-in list methods (i.e. append(), max(), index() ) to make the program small and simple, make sure you have an idea about what these methods returns and what is their work.

If you are not familiar with them or want to recall them, then do check the method's information and syntax given below -

1. append(): Used for appending and adding elements to List. It is used to add elements to the last position of List.
Syntax:

list.append(element)

2. max(): Calculates and returns maximum of all the elements of List.
Syntax:

max(list)

3. index(): Returns the index of element present in the list. If there are more than one occurence of any element in the list then it returns the index of first occurrence.
Syntax:

list.index(element)

Do refer the screenshot of the code for proper indentation and error free execution.

PROGRAM -

sales=list()
customer=list()

def nameofBestCustomer(Sales,Customers):
    max_sales=Sales.index(max(Sales))
    return Customers[max_sales]
        
    
while True:
    c=input("\nEnter Customer: ")
    customer.append(c)
    s=int(input("Enter Sales: "))
    sales.append(s)
    
    if s==0:
        break

best_customer=nameofBestCustomer(sales,customer)
print("\n\nName of the best customer is: " + best_customer)

SAMPLE 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
Question 1 of 15 Linsay’s Landscaping wants to make notes in QuickBooks each time she services...
Question 1 of 15 Linsay’s Landscaping wants to make notes in QuickBooks each time she services a client to streamline the invoicing process at the end of the month. She does not want these records to affect any month or year to date financial reports throughout the month until she invoices the client. Which of the following transaction types do you recommend she uses to achieve this goal? A. Invoice B. Credit Memo C. Sales Receipt D. Delayed Charge E....
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the purchases and fixed assets business areas. Prepare a 12- to 16-slide presentation describing the purchases and fixed assets business areas. Be sure to incorporate speaker notes as well as appropriate visuals, graphics, fonts, etc. Include any associated risk in these areas. Describe specific internal controls that include authorization of transactions, segregation of duties, adequate records and documentation, security of assets, and independent checks and...
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From...
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From the April 2004 Issue Save Share 8.95 In 1991, Progressive Insurance, an automobile insurer based in Mayfield Village, Ohio, had approximately $1.3 billion in sales. By 2002, that figure had grown to $9.5 billion. What fashionable strategies did Progressive employ to achieve sevenfold growth in just over a decade? Was it positioned in a high-growth industry? Hardly. Auto insurance is a mature, 100-year-old industry...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT