In pyhton. Pleaseee A supermarket wants to reward its best customer of each day,
ID: 673606 • Letter: I
Question
In pyhton. Pleaseee
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 purchase amount is stored in a list and the customer’s name is stored in a corresponding list.Implement a function:
Def nameofBestCustomer(Sales, customers)
That returns the name of the customer with the largest sale.
Write a program that prompts the cashier to enter all prices and names, adds them to two lists, calls the function that you implemented, and displays the result. Use a price of 0 as a sentinel.
Explanation / Answer
def nameOfBestCustomer(Sales,customers):
l = len(Sales)
mx = 0
cust_name = ''
for i in range(0,l):
if Sales[i] > mx :
mx = Sales[i]
cust_name = customers[i]
return cust_name
l = 0
sale =[]
customer = []
while 1:
x = input('Enter customer sale: ')
x = int(x)
if x == 0:
break
y = input('Enter customer name: ')
sale.append(x)
customer.append(y)
l = l + 1
print( nameOfBestCustomer(sale,customer) )