A priority queue is a data structure where each element has a priority. Elements are inserted with a priority number. The queue always keeps the element with the highest priority (lowest number) at the front. When removing, the element with the highest priority is taken out first. This is different from a normal queue that works by order of insertion. The priority queue is often implemented using a heap, which keeps the elements partially ordered for fast access. In the example, we insert tasks with priorities 2 and 1. The queue reorders to put the task with priority 1 first. Removing elements takes out the highest priority task each time. Trying to remove from an empty queue raises an IndexError (using heapq). This structure is useful when some tasks must be done before others based on priority.