Complete the code to declare a direct exchange named 'logs'.
channel.exchange_declare(exchange='logs', exchange_type='[1]')
The direct exchange type routes messages with a specific routing key to queues bound with that key.
Complete the code to bind the queue 'error_logs' to the exchange 'logs' with routing key 'error'.
channel.queue_bind(queue='error_logs', exchange='logs', routing_key='[1]')
Binding with routing key 'error' ensures that messages sent with this key are routed to the 'error_logs' queue.
Fix the error in the code to publish a message with routing key 'info' to the 'logs' exchange.
channel.basic_publish(exchange='logs', routing_key='[1]', body='System started')
The routing key must match the intended message type, here 'info' to route correctly.
Fill both blanks to create a dictionary comprehension that maps routing keys to their message counts only if the count is greater than 5.
{key: counts[1] for key in counts if counts[key][2] 5}The comprehension uses counts.get(key, 0) to safely get counts and filters keys with counts greater than 5.
Fill all three blanks to create a dictionary comprehension that maps uppercase routing keys to their counts only if count is greater than 10.
{ [1]: [2] for [3] in counts if counts[[3]] > 10 }The comprehension maps uppercase keys to their counts, iterating over keys and filtering counts greater than 10.