nlargest heapq

heapq.nlargest(3, li1)

Here is what the above code is Doing:
1. We have imported the heapq module.
2. We have created a list li1.
3. We have used the heapify() function to convert the list into a heap.
4. We have used the heappush() function to push the elements into the heap.
5. We have used the heappop() function to pop the elements from the heap.
6. We have used the heapreplace() function to replace the first element of the heap with the last element of the heap.
7. We have used the nlargest() function to find the largest element from the list.
8. We have used the nsmallest() function to find the smallest element from the list.