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!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

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)

27th Apr 2021, 3:22 PM
Emmanuel Massawe
Emmanuel Massawe - avatar
12 Answers
+ 5
#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 )
12th Dec 2021, 1:52 PM
Mahsaaarabi
Mahsaaarabi - avatar
+ 1
time=0 #your code goes here while not c.is_empty(): a = c.next() if a == "general": time += 5 elif a == "technical": time += 10 print(time)
16th Aug 2022, 1:53 PM
Tsion Hailye Tasew
Tsion Hailye Tasew - avatar
+ 1
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() while True: n = input() if n == 'end': break c.add(n) #your code goes here time=0 while not c.is_empty(): a = c.next() if a == "general": time += 5 elif a == "technical": time += 10 print(time)
17th Aug 2022, 4:52 PM
Hamza Shafiq
Hamza Shafiq - avatar
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)
27th Apr 2021, 3:49 PM
Haidar Mazen Hasan
Haidar Mazen Hasan - avatar
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
28th May 2021, 12:31 PM
Abhishek Biswas
Abhishek Biswas - avatar
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
30th May 2021, 7:58 AM
Alex G.
Alex G. - avatar
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)
13th Jun 2021, 12:31 PM
Sachin KS
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)
27th Feb 2022, 1:55 PM
achmad mustafa
achmad mustafa - avatar
0
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 )
12th Nov 2022, 10:50 AM
Pooja Patel
Pooja Patel - avatar
0
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() while True: n = input() if n == 'end': break c.add(n) #your code goes here time=0 while not c.is_empty(): a = c.next() if a == "general": time += 5 elif a == "technical": time += 10 print(time)
19th Nov 2022, 1:14 AM
Mohamed Gomaa Soliman
0
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() while True: n = input() if n == 'end': break c.add(n) time = 0 for i in c.customers: if i == "technical": time += 10 elif i == "general": time += 5 else : time += 0 print(time)
9th Dec 2022, 7:47 AM
Pareshkumar Chaudhari
- 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
24th May 2021, 2:52 PM
Alex G.
Alex G. - avatar