Where do i make mistake in these codes? As my codes have passed all tests except one.Any hint or help here? | Sololearn: Learn to code for FREE!

+4

Where do i make mistake in these codes? As my codes have passed all tests except one.Any hint or help here?

You are making a call center application, which should handle customers in a queue. The CallCenter class is implemented as a Queue. Each element of the queue has the topic of the call as its value. The two possible values are 'general' and 'technical'. A 'general' call takes on average 5 minutes to handle, while a 'technical' call requires 10 minutes. The given code adds multiple customers to the Queue from user input. You need to dequeue all added customers, calculate and output the total time required to handle all calls. I tried to resolve it but my codes still fail to pass one test. Can anyone assist to point out what my codes miss to fulfil all the tests in this assignment ? class CallCenter: def __init__(self): self.customers = [] def is_empty(self): return self.customers == [] def add(self, x): self.customers.insert(0, x) def next(self): return self.customers.pop() c = CallCenter() gcount=0 tcount=0 while True: n = input() if n == 'end': break c.add(n) c.next() if n=='general': gcount+=1 #print(gcount) tg_time=gcount*5 elif n=='technical': tcount+=1 #print(tcount) tt_time=tcount*10 ttg_time=tg_time+tt_time print(ttg_time)

4/27/2021 3:22:24 PM

ManuuπŸ‰πŸΆ

7 Answers

New Answer

+3

#this code is true πŸ‘©β€πŸ’» class CallCenter: def __init__(self): self.customers = [] def is_empty(self): return self.customers == [] def add(self, x): self.customers.insert(0, x) def next(self): return self.customers.pop() c = CallCenter() time_count=0 while True: n = input() if n == 'end': break c.add(n) if n=="general": time_count +=5 elif n =="technical": time_count+=10 c.next() print(time_count )

0

Just put a closed bracket at the end of the print statement on the last line of your code: class CallCenter: def __init__(self): self.customers = [] def is_empty(self): return self.customers == [] def add(self, x): self.customers.insert(0, x) def next(self): return self.customers.pop() c = CallCenter() gcount=0 tcount=0 while True: n = input() if n == 'end': break c.add(n) c.next() if n=='general': gcount+=1 #print(gcount) tg_time=gcount*5 elif n=='technical': tcount+=1 #print(tcount) tt_time=tcount*10 ttg_time=tg_time+tt_time print(ttg_time)

0

please help me...the code pass the all test but it didnot pass the last test class CallCenter: def __init__(self): self.customers = [] def is_empty(self): return self.customers == [] def add(self, x): self.customers.insert(0, x) def next(self): return self.customers.pop() c = CallCenter() gcount=0 tcount=0 while True: n = input() if n=='general': gcount+=1 g_time=gcount*5 elif n=='technical': tcount+=1 t_time=tcount*10 elif n == 'end': break c.add(n) c.next() r=g_time+t_time print(r) please tell me whre the mistake i have done

0

Hi Abhishek, your code is grand, it's just that you'll need to set the 't_time' and 'g_time' variables before the while loop. And that should be it, you were really close the the answer. Alex

0

#This code works class CallCenter: def __init__(self): self.customers = [] def is_empty(self): return self.customers == [] def add(self, x): self.customers.insert(0, x) def next(self): return self.customers.pop() c = CallCenter() time_count=0 while True: n = input() if n == 'end': break c.add(n) if n=="general": time_count+=5 elif n=="technical": time_count+=10 c.next() print(time_count)

0

maybe this is good: class Callcenter: def __init__(self): self.custumors = [] def is_empty(self): return self.custumors == [] def add(self, x): self.custumors.insert(0, x) def next(self): return self.custumors.pop() c = Callcenter() value = 0 while True: n = input() if n == 'end': break c.add(n) while True: if c.is_empty(): break if c.custumors[-1] == 'general': value += 5 elif c.custumors[-1] == 'technical': value +=10 else: value += 0 c.next() print(value)

-1

Hi lads, had a rough time with this quiz as well. The main issue is that if you start the script with no values and hit 'end', it will cause you an error. That's just a hint, if you won't figure it out after this, just tell me and I'll give you the answer. It's just that if you find the answer yourself, it's way more sweeter than just seeing a post. Alex