n largest and n smallest in list in python

Solutions on MaxInterview for n largest and n smallest in list in python by the best coders in the world

showing results for - "n largest and n smallest in list in python"
Jazmín
10 Jun 2016
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]
Luciano
07 Mar 2020
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))
Lou-Ann
14 Jan 2019
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]))
queries leading to this page
find largest and smallest number in array pythonpython get smallest number in list4 18 lab 3a smallest and largest numbers in a list pythonhow to find the smallest whole number in a list pythonprogram to find largest and smallest element in an array in pythonhow to print the smallest number in a list pythonsmallest number from list pythonreturn the smallest number in the listn largest and smallest element in list pythonfinding all the smallest numbers up to n in an listpython find the smallest number in a list sorting a list smallest to biggest number in pythonfind the smallest value in a list of lists pythonfind the largest and smallest number in a listfind the smallest positive integer in a listways to find smallest integer not in list pythonreturn biggest and smallest number in a undetermined list pythonn largest and n smallest in list in python6 how to find the largest and lowest value in the list 3ffinding the difference between the largest and smallest from a list of 5 numbersfind largest and smallest number in pythonpython find the smallest number in a list than next elementfind the largest and smallest numbers in a listfind smallest number in python listprogram to find the smallest number in an array pythonfind smallest list of elements that are present in all arrayshow to find the smallest int in a listhow to get the smallest number in a list of list in pythonpython how to sort from biggest to smallest in an arrayprint smallest number in list pythonwrite a python program to find the largest and smallest number in a listsmallest number in list pythongenerate list from smallest to largest pythonhow to list smallest to largest values pythonhow to find the largest number in a listfind the smallest and second smallest numbers from the list 28code in python 294 18 lab 3a smallest and largest numbers in a listreturn biggest and smallest number in a list pythonfind the smallest integer in list pythonfind largest and smallest number in an array in pythonpython find smallest number in listfind smallest item in listsmallest number from listhow to check a largest number and smallest in a list using if in the sam eprogramhow to get the smallest integer in a listto find the largest and smallest numbers in a list return biggest and smallest number in an undetermined list pythonhow do you find the ith smallest value in a list pythonpython best way to get smallest and biggest numberfind the smallest number in a list pythonfind the smallest number in list pythonfind smallest number in list pythonpython find first and second largest value in listsmallest number possible from list of given numbers in pythonpython program to find the largest and smallest number in a listpython smallest number in listpython program to find smallest number in a listpython find smallest value in listhow to find smallest number in list pythonhow to find smallest and largest number in list in pythonhow to find the smallest number in a list python8 29 29write a python program to get the largest and smallest number from a list write a python program to get smallest number from a listhow to check the smallest number in a listhow to orginize a list from biggest number to smallesthow to sort a list from smallest to largest pythonhow to order lists from biggest to smallest pythonhow to find the smallest value in a list pythonhow to get smallest and largest number of list in pythonhow to find the smallest item in a list pythonhow to check a largest number and smallest in a list using if in the sam e programreturning the largest and smallest numbers in an array pythonfind the smallest and second smallest numbers from the listpython get the smallest numbers in a listfind two smallest numbers in list pythonhow to get the smallest number in a list in pythonfind the smallest integer that greater than the minimum number in a list pythonhow to print the smallest number of most frequent elements in listdifference between largest and smallest number in array in python1 find the largest 2fsmallest number in a given list of ten 8 bit numbers find largest and smallest numbers in a listget the smallest integer in listhow to get smallest number in list pythonn largest and n smallest in list in python