Question: In Python create the Retail Store Application. A retail store wants to know its top customers of each week, that is, the first topN customers
In Python create the Retail Store Application. A retail store wants to know its top customers of each week, that is, the first topN customers with the largest sales, where topN is a value that the user of the program supplies. Implement a function def nameOfBestCustomer(sales, customer, topN) that returns the names of the topN customers with the largest sales. The application prompts the user to enter a value for topN. Then it asks for all prices and names, calls the function that you implemented, and displays the results. If there were fewer than topN customers entered by the user, the application should output all the customers entered. Use character x as a sentinel. I currently have written this
def nameofBestCustomer(sales, customer, topN): sale = max(sales) index = sales.index(sale) bestCustomer = customer[index] count = topN if count > len(sales): count = len(sales) print("The best customers were: ", customer) for i in range(0, count): print(customer[i])
sales = [] customer = [] count = int(input("Enter number of top customers: ")) sales = input("Enter the sale amount (x to quit): ")
while sales != 'x': sales.append(int(sales)) customer.append(input("Enter the customer name: ")) sales = input("Enter the sale amount (x to quit): ")
bestCustomer = nameofBestCustomer(sales, customer, count)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
