Answers for "how to compare a number with smallest and biggest number python"

1

n-largest and n-smallest in list in python

import heapq

grades = [110, 25, 38, 49, 20, 95, 33, 87, 80, 90]

print(heapq.nlargest(3, grades))
print(heapq.nsmallest(4, grades))

[110, 95, 90]
[20, 25, 33, 38]
Posted by: Guest on August-27-2021
0

find the smallest number in list by comparison python

def smallest_num_in_list( list ):
    min = list[ 0 ]
    for a in list:
        if a < min:
            min = a
    return min
Posted by: Guest on January-26-2021

Code answers related to "how to compare a number with smallest and biggest number python"

Python Answers by Framework

Browse Popular Code Answers by Language