Complete the code to create a new connection to RabbitMQ.
connection = pika.BlockingConnection(pika.ConnectionParameters('[1]'))
The connection to RabbitMQ is created by specifying the host, usually 'localhost' for local servers.
Complete the code to open a new channel from the connection.
channel = connection.[1]()To open a channel, call the 'channel()' method on the connection object.
Fix the error in the code to properly close the channel.
channel.[1]()The correct method to close a channel is 'close()'.
Fill both blanks to create a dictionary comprehension that maps channel IDs to their status if the channel is open.
{ch_id: ch.status for ch_id, ch in channels.items() if ch.[1] == [2]We check if the channel's 'is_open' attribute is True to filter open channels.
Fill all three blanks to create a dictionary comprehension that maps connection names to their channels if the channel is open.
{conn_name: ch for conn_name, ch in connections.items() if ch.[1] and ch.[2] == [3]The comprehension filters channels that are open by checking 'is_open' attribute and 'status' equals 'open'.