Aug-04-2021, 06:10 PM
(This post was last modified: Aug-04-2021, 07:21 PM by Yoriz.
Edit Reason: Added code tags
)
Money Bank operates several branches in a city. Each bank branch offers financial services. The branch manager of the bank wants to know the most visited service counter in a day. The details of the financial services are stored in a dictionary as follows:
Write a python function most_visited_service (). The function will find the financial service visited by the maximum number
of customers and return the name of the service. If the maximum number of customers is equal for more than one service,
return the list of all respective services. If the input has a service which is not mentioned in the dictionary,
perform error handling then print “Service not found”
Test your code by using the sample inputs given below:
Thanks
Sushma
{ "L" : "Loans", "C" : "Credit Cards", "M" : "Mutual Funds", "I" : "Insurance" }The customer id of the customer along with the service counter visited by the customer is stored in a list as given below:
[409,’L’,505,’L’,304,’M’,209,’I’]Problem:
Write a python function most_visited_service (). The function will find the financial service visited by the maximum number
of customers and return the name of the service. If the maximum number of customers is equal for more than one service,
return the list of all respective services. If the input has a service which is not mentioned in the dictionary,
perform error handling then print “Service not found”
Test your code by using the sample inputs given below:
Output:Sample Input Expected Output
[409,’L’,505,’L’,304,’M’,209,’I’,809,’I’,409,’L’] Loans
[409,’L’,505,’L’,304,’M’,209,’I’,409,’M’] [“Loans”, “Mutual Funds”]
[202,’L’,407,’X’,809,’I’,409,’L’] Service not found
Solution:Bank_Services = { "L" : "Loans", "C" : "Credit Cards", "M" : "Mutual Funds", "I" : "Insurance" } print(Bank_Services) print(Bank_Services['L']) print(Bank_Services['C']) print(Bank_Services['M']) print(Bank_Services['I']) Cust_List =[409,'L',505,'L',304,'M',209,'I'] print(Cust_List) Cust_ID =[409,505,304,209,809,202,407] print(Cust_ID)Can some one please help me how to write the next code
Thanks
Sushma