create a queue python code example
Example 1: queue python
from queue import Queue
q = Queue()
q.size()
q.empty()
q.put(item)
q.get()
Example 2: python list as queue
queue = []
queue.append('a')
queue.append('b')
print(queue)
print("\nElements dequeued from queue")
print(queue.pop(0))
print(queue.pop(0))
print("\nQueue after removing elements")
print(queue)
Example 3: queue in python
my_queue =[]
my_queue.append(1)
my_queue.append(2)
my_queue.append(3)
my_queue.append(4)
my_queue.append(5)
print("The items in queue:")
print(my_queue)
print(my_queue.pop(0))
print(my_queue.pop(0))
print(my_queue.pop(0))
print(my_queue.pop(0))
print("The items in queue:")
print(my_queue)