School Revise · Class 11 Computer Science · Chapter 4
Code 083, Class 12. A queue serves items in the order they arrive, first in first out, like a line at a shop. Here we build a queue with a Python list.
|
|
A queue stores items so the first one added is the first one removed. This is FIFO, first in first out, like people waiting in a line.
A list works as a queue. append() adds at the rear (enqueue) and pop(0) removes from the front (dequeue).
|
queue = [] queue.append(10) queue.append(20) print(queue.pop(0)) Output: 10 |
The front is queue[0] and the rear is queue[-1]. The queue is empty when its length is zero.
Queues are used for printer jobs, for tasks waiting to run, and for messages, because the fair order is first come first served.
Explore the idea by tapping. The interactive opens right here in the lesson.
Write and run real Python right here in the lesson, then work through the practice problems with answers.
Type each one into the code lab above, then open the card to see the worked solution and its output.
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
FIFO, first in first out.
append().
pop(0).
queue[0].
|
A queue is FIFO: the first item added is the first removed. A Python list is used as a queue: append() enqueues at the rear and pop(0) dequeues from the front. queue[0] is the front and queue[-1] is the rear. Queues suit printer jobs and any first come first served task. |
| Open the Virtual Lab |
These free Class 12 Computer Science notes explain the queue data structure, FIFO, enqueue and dequeue using a Python list, and where queues are used with worked examples and practice, for CBSE students across India and the Gulf including the UAE, Saudi Arabia, Qatar, Oman, Kuwait and Bahrain.
© 2026 School Revise. All rights reserved. Original content aligned to the CBSE and NCERT Class 12 Computer Science syllabus. Unauthorised copying is not permitted.