Complete the code to declare a durable queue named 'task_queue'.
channel.queue_declare(queue='task_queue', durable=[1])
Setting durable=True makes the queue survive RabbitMQ restarts, which is important for work queues.
Complete the code to send a persistent message to the 'task_queue'.
channel.basic_publish(exchange='', routing_key='task_queue', body=message, properties=pika.BasicProperties(delivery_mode=[1]))
Setting delivery_mode=2 marks the message as persistent, so it won't be lost if RabbitMQ restarts.
Fix the error in the consumer code to acknowledge messages manually.
channel.basic_consume(queue='task_queue', on_message_callback=callback, auto_ack=[1])
Setting auto_ack=False means the consumer will send an acknowledgment after processing each message, which is important for work queues.
Fill both blanks to set prefetch count to 1 and declare a durable queue.
channel.basic_qos(prefetch_count=[1]) channel.queue_declare(queue='task_queue', durable=[2])
Setting prefetch_count=1 tells RabbitMQ not to give more than one message to a worker at a time. Declaring the queue as durable ensures it survives restarts.
Fill all three blanks to create a dictionary comprehension that maps each word to its length only if length is greater than 3.
lengths = { [1] : [2] for [3] in words if len([3]) > 3 }This comprehension creates a dictionary where keys are words and values are their lengths, but only for words longer than 3 characters.