1import heapq
2
3grades = [110, 25, 38, 49, 20, 95, 33, 87, 80, 90]
4
5print(heapq.nlargest(3, grades))
6print(heapq.nsmallest(4, grades))
7
8[110, 95, 90]
9[20, 25, 33, 38]
1#Exercise 3 - Find the largest and smallest number in a list
2thislist = input("How many numbers do you want to enter:")
3newlist = []
4for x in range (0, int(thislist)):
5 owl = int(input("Please Enter your numbers:"))
6 newlist.append(owl)
7print ("The max number entered is:", max(newlist))
8print ("The min number entered is:", min(newlist))
1thislist = [677,8765,8765,876,470,754,6784,56789,7658,]
2thislist.sort()
3print ("The smallest number is: " + str(thislist[0]))
4print ("The largest number is: " + str(thislist[-1]))