Answers for "april 24 th tcs cpa answer"

0

april 24 th tcs cpa answer

class Boutique:
    def __init__(self,boutiqueid,boutiquename,boutiquetype,boutiquerating,points):
        self.boutiqueid= boutiqueid
        self.boutiquename = boutiquename
        self.boutiquetype = boutiquetype
        self.boutiquerating = boutiquerating
        self.points = points

class OnlineBoutiue:
    def __init__(self,boutiquedict):
        self.boutiquedict = boutiquedict

    def getboutique(self,ll,ul,ep,types):
        lst =[]
        if types.lower() in self.boutiquedict.keys():#4
            lists = self.boutiquedict[types.lower()]            
            for item in lists:
                if item.boutiquerating>=ll and item.boutiquerating<=ul:
                    item.points += ep
                    lst.append(item)
                else:
                    lst.append(item)
            orderedList = sorted(lst,key=lambda x:x.points,reverse=True)#5
            return orderedList
        else:
            return None

n = eval(input())
lists= []
for i in range(n): #1
    boutiqueid = eval(input())
    boutiquename = input()
    boutiquetype =input().lower()
    boutiquerating = eval(input())
    points= eval(input())
    lists.append(Boutique(boutiqueid, boutiquename, boutiquetype, boutiquerating, points))

dicts = {} 
for item in lists: #2
    if item.boutiquetype.lower() in dicts.keys():
        dicts[item.boutiquetype.lower()].append(item)

    else:
        dicts[item.boutiquetype.lower()]=[]
        dicts[item.boutiquetype.lower()].append(item)

y = OnlineBoutiue(dicts)
ll = eval(input())
ul = eval(input())
ep = eval(input())
types = input()
lst= y.getboutique(ll,ul,ep,types) #3
if lst == None:
    print("No boutique found")
else:
    for item in lst:
        print(item.boutiqueid,item.boutiquename,item.points)
Posted by: Guest on May-01-2021

Browse Popular Code Answers by Language