In Python, to implement a Double-Ended Queue (Deque), we need to import the collections module. The collections module provides a range of specialized container data types in addition to Python's built-in containers such as lists, dictionaries, and tuples. One of these is deque (double-ended queue), which supports thread-safe, memory-efficient appends and pops from either side of the deque with approximately the same O(1) performance in either direction.
To use a deque, you can import and initialize it as follows:
from collections import deque
dq=deque()With deque, you can perform operations such as append() and appendleft() for adding elements, along with pop() and popleft() for removing them from either end.
In Python, the collections module needs to be imported for implementing a Double Ended Queue (Deque).
Additional Context:
deque class for double-ended queues
from collections import deque
d = deque([1, 2, 3])
d.appendleft(0) # Add to front
d.append(4) # Add to end
Correct Answer: (2) collections.
| List-I | List-II |
| (A) readline() | (I) Writes a sequence of strings to the file |
| (B) writelines() | (II) Reads a single line from the file |
| (C) seek() | (III) Force any buffered output to be written to the file |
| (D) flush() | (IV) Moves the file pointer to the specified position |
Select the statements that are CORRECT regarding patterns of biodiversity.
Which of the following hormone is not produced by placenta ?
List - I | List - II | ||
| A | Streptokinase | I | Blood-Cholestrol lowering agents |
| B | Cyclosporin | II | Clot Buster |
| C | Statins | III | Propionibacterium sharmanii |
| D | Swiss Cheese | IV | Immuno suppressive agent |
Which of the following option determines percolation and water holding capacity of soils ?