Objective
Create a Python program that manages a priority queue of tasks with the heapq module: the task with the lowest priority number always runs first.
Instructions
- Read an integer
nand thenncommands. Names have no spaces and priorities are integers. add PRIORITY NAME: adds the task and showsAdded: NAME.run: pops the task with the lowest priority and showsRunning: NAME (priority P). On a tie, the one added first goes first (store a counter next to the priority). If there are no tasks, showNo tasks.- At the end, show
Pending: Kwith the tasks left.
6
add 3 informe
add 1 backup
add 3 correo
run
run
run
Added: informe
Added: backup
Added: correo
Running: backup (priority 1)
Running: informe (priority 3)
Running: correo (priority 3)
Pending: 0
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise