Challenge: Handling Customer Requests
Tarea
Swipe to start coding
You are tasked with managing a customer support system where customer requests are handled in the order they arrive. However, high-priority requests must be added to the front of the queue. To achieve this:
- Initialize the appropriate data structure to maintain the queue of customer requests.
- If the required data structure needs to be imported, include the appropriate import statement. Otherwise, remove the import line.
- Add regular customer requests to the end of the queue.
- Add high-priority customer requests to the front of the queue.
- Process requests in the order they should be handled (removing from the front).
Solución
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from collections import deque
# Initialize an empty customer support queue
customer_queue = deque()
# Add requests to the end
customer_queue.append('Request 1')
customer_queue.append('Request 2')
# Add a high-priority request to the front
customer_queue.appendleft('High-Priority Request')
# Process requests in the correct order
while customer_queue:
# Remove from the front
current_request = customer_queue.popleft()
print(f"Processing: {current_request}")
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 2. Capítulo 5
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from ___ import ___
# Initialize an empty customer support queue
customer_queue = ___
# Add requests to the end
customer_queue.___('Request 1')
customer_queue.___('Request 2')
# Add a high-priority request tp the front
customer_queue.___('High-Priority Request')
# Process requests in the correct order
while customer_queue:
# Remove from the front
current_request = customer_queue.___()
print(f"Processing: {current_request}")
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla