<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Python Collections Quick Reference
Table Of Contents
<a href="#1.-Deque">Deque</a>
<a href="#2.-Heapq">Heapq</a>
<a href="#3.-Counter">Counter</a>
1. Deque
Step1:  Using maxlen to limit the num of items in a deque
Step2:  2. Heapq
heapq provides O(1) access to the smallest item in the heap.
Step3:  nlargest / nsmallest wraps creation of a heap for one-time access
Step4:  3. Counter
<ASSISTANT_TASK:>
Python Code:
from collections import deque
dq = deque()
dq.append(1)
dq.append(2)
dq.appendleft(3)
dq
v = dq.pop()
v
dq.popleft()
dq
Explanation: Python Collections Quick Reference
Table Of Contents
<a href="#1.-Deque">Deque</a>
<a href="#2.-Heapq">Heapq</a>
<a href="#3.-Counter">Counter</a>
1. Deque
End of explanation
dq = deque(maxlen = 3)
for n in range(10):
    dq.append(n)
dq
Explanation: Using maxlen to limit the num of items in a deque
End of explanation
import heapq
nums = [1, 8, 2, 23, 7, -4, 18, 23, 42, 37, 2]
#heapq is created from a list
heap = list(nums)
heapq.heapify(heap)
#now the 1st element is guarenteed to be the smallest
heap
heapq.heappop(heap)
heap
heapq.heappush(heap, -10)
heap
Explanation: 2. Heapq
heapq provides O(1) access to the smallest item in the heap.
End of explanation
# nlargest and nsmallest wrap a heapq to provide its results
print(heapq.nlargest(3, nums)) # Prints [42, 37, 23]
print(heapq.nsmallest(3, nums)) # Prints [-4, 1, 2]
# providing an alternate sort key to nlargest/nsmallest
portfolio = [
{'name': 'IBM', 'shares': 100, 'price': 91.1},
{'name': 'AAPL', 'shares': 50, 'price': 543.22},
{'name': 'FB', 'shares': 200, 'price': 21.09},
{'name': 'HPQ', 'shares': 35, 'price': 31.75},
{'name': 'YHOO', 'shares': 45, 'price': 16.35},
{'name': 'ACME', 'shares': 75, 'price': 115.65}
]
heapq.nsmallest(3, portfolio, key=lambda s: s['price'])
Explanation: nlargest / nsmallest wraps creation of a heap for one-time access
End of explanation
words = [
'look', 'into', 'my', 'eyes', 'look', 'into', 'my', 'eyes',
'the', 'eyes', 'the', 'eyes', 'the', 'eyes', 'not', 'around', 'the',
'eyes', "don't", 'look', 'around', 'the', 'eyes', 'look', 'into',
'my', 'eyes', "you're", 'under'
]
from collections import Counter
word_counts = Counter(words)  #Works with any hashable items, not just strings!
word_counts.most_common(3)
morewords = ['why','are','you','not','looking','in','my','eyes']
for word in morewords:
    word_counts[word] += 1
word_counts.most_common(3)
evenmorewords = ['seriously','look','into','them','while','i','look','at', 'you']
word_counts.update(evenmorewords)
word_counts.most_common(3)
a = Counter(words)
b = Counter(morewords)
c = Counter(evenmorewords)
# combine counters
d = b + c
d
# subtract counts
e = a-d
e
Explanation: 3. Counter
End of explanation
<END_TASK>