Python 3.4 - Finding Largest or Smallest Items

Importing the heapq function allows for us to get specific data from a list or dictionary:

import heapq

grades = [32, 42, 54, 56, 66, 78, 99]

print(heapq.nlargest(3, grades))


/Users/mattfassnacht/PycharmProjects/untitled6/venv/bin/python /Users/mattfassnacht/PycharmProjects/untitled6/functions.py
[99, 78, 66]

Process finished with exit code 0

https://www.youtube.com/watch?v=iiQqilwChw4

Comments

Popular posts from this blog

Pyhton 3.4 - Continue

Conversations Ongoing: Valuing Modernization in Early European History

Conversations Ongoing: A Bunch of Amateurs