Queue in Python:
===============
A Queue is an ordered collection of items where the addition of new items happens at one end called "Rear" and removal of items occur at other called as "Front"
Queue follows the First in first out (FIFO) principal it means which item entered first will remove from queue first. Have you ever stood in ATM queue? what is the rule who is first in queue will get money and leave. It is important for Threaded programming.
Now what is Thread? Thread is a single sequential flow of control within program.
The addition of an item in queue called Enqueue and removal called Dequeue.
Queue in Python Implemented by :
1) List
2) queue library
Methods in Queue:
===========================
1) queue() - creates and empty queue
2 ) enqueue() - Add item in Queue
3) dequeue() -It will remove the item from queue which is added first
4) isEmpty() - like isEmpty return Boolean value
5) size() - it will return the size of queue
Implementation Using List:
The out put is:
True # Boolean value
5 # initial added item removed
2 # size of queue once item removed
Implementation Using Queue library:
===============================================
To implement this first you need to install queue library. I suggest you to follow instruction given Queue install
In queue library adding of item called as put. means enqueue() we created above replaced by put(), and removal means dequeue() replaced by get()
I suggest you to follow the official documentation for queue library Queue Documentation
(note: the methods used in library may be different than i used above)