Python program to find smallest number in a list Last Updated : 23 Oct, 2024 Comments Improve Suggest changes Like Article Like Report In this article, we will discuss various methods to find smallest number in a list. The simplest way to find the smallest number in a list is by using Python's built-in min() function.Using min()The min() function takes an iterable (like a list, typle etc.) and returns the smallest value. Python a = [8, 3, 5, 1, 9, 12] # Find the smallest number smallest = min(a) print(smallest) Output1 Let us explore different methods to find smallest number in a list.Table of ContentUsing a For LoopUsing SortingFrequently Asked Questions on Finding Smallest Number in ListUsing a For LoopWe can also find the smallest number in a list without using any built-in methods by using a loop (for loop). This method is useful for understanding how the comparison process works step by step. Python a = [8, 3, 5, 1, 9, 12] # Initialize "smallest" value with first element of list smallest = a[0] # Iterate through list to find smallest element for val in a: # If current value is smaller than current smallest value if val < smallest: # Update the smallest value smallest = val print(smallest) Output1 Using SortingAnother way to find the smallest number in a list is by sorting it. Once sorted in ascending order, the smallest number will be at the beginning of the list. Python a = [8, 3, 5, 1, 9, 12] a.sort() smallest = a[0] print(smallest) Output1 Explanation:The sort() function sorts the list in ascending order.After sorting, the first element (a[0]) will be the smallest.Note: This method is not recommended for finding the smallest number in a list. While it works but it is less efficient than using min() or a for loop. Sorting has a time complexity of O(n log n), whereas the other methods are O(n). Comment More infoAdvertise with us Next Article Python program to find smallest number in a list S Shivam_k Follow Improve Article Tags : Python Python Programs python-list Python list-programs python +1 More Practice Tags : pythonpythonpython-list Similar Reads Python program to find the smallest number in a file Given a text file, write a Python program to find the smallest number in the given text file.Examples:Input: gfg.txtOutput: 9Explanation: Contents of gfg.txt: I live at 624 Hyderabad.My mobile number is 52367. My favourite number is 9.Numbers present in the text file are 9,624,52367Minimum number is 3 min read Python3 Program to Find the smallest missing number Given a sorted array of n distinct integers where each integer is in the range from 0 to m-1 and m > n. Find the smallest number that is missing from the array. Examples Input: {0, 1, 2, 6, 9}, n = 5, m = 10 Output: 3Input: {4, 5, 10, 11}, n = 4, m = 12 Output: 0Input: {0, 1, 2, 3}, n = 4, m = 5 4 min read Python Program to Find Largest Number in a List Finding the largest number in a list is a common task in Python. There are multiple way to do but the simplest way to find the largest in a list is by using Python's built-in max() function:Using max()Python provides a built-in max() function that returns the largest item in a list or any iterable. 3 min read Python program to find the Decreasing point in List Given a list, get the index of element where the list shows the first negative trend, i.e first point where the next element < current element. If not found return -1. Input : test_list = [3, 6, 8, 9, 12, 5, 18, 1] Output : 4 Explanation : At 12 -> 5, first decreasing point occurs. Input : tes 4 min read Python program to list Sort by Number value in String Given a List of strings, the task is to write a Python program to sort list by the number present in the Strings. If no number is present, they will be taken to the front of the list. Input : test_list = ["gfg is 4", "all no 1", "geeks over 7 seas", "and 100 planets"] Output : ['all no 1', 'gfg is 4 6 min read Python Program to Find closest number in array Given an array of sorted integers. We need to find the closest value to the given number. Array may contain duplicate values and negative numbers. Examples: Input : arr[] = {1, 2, 4, 5, 6, 6, 8, 9} Target number = 11 Output : 9 9 is closest to 11 in given array Input :arr[] = {2, 5, 6, 7, 8, 8, 9}; 4 min read Python program to find the smallest word in a sentence Given a string S of lowercase English alphabets, the task is to print the smallest word in the given string. Examples: Input: S = âsky is blueâOutput: "is"Explanation: Length of âskyâ is 3.Length of is âisâ 2.Length of âblueâ is 4.Therefore, the smallest word is âisâ. Input: S = âgeeks for geeksâOut 5 min read Python - Find Minimum Pair Sum in list Sometimes, we need to find the specific problem of getting the pair which yields the minimum sum, this can be computed by getting initial two elements after sorting. But in some case, we donât with to change the ordering of list and perform some operation in the similar list without using extra spac 4 min read Python | Find missing numbers in a sorted list range Given a range of sorted list of integers with some integers missing in between, write a Python program to find all the missing integers. Examples: Input : [1, 2, 4, 6, 7, 9, 10] Output : [3, 5, 8] Input : [5, 6, 10, 11, 13] Output : [7, 8, 9, 12] Method #1: List comprehension Python # Python3 progra 5 min read Python | Find closest number to k in given list Given a list of numbers and a variable K, where K is also a number, write a Python program to find the number in a list which is closest to the given number K. Examples: Input : lst = [3.64, 5.2, 9.42, 9.35, 8.5, 8], K = 9.1 Output : 9.35 Input : lst = [9, 11, 5, 3, 25, 18], K = 6 Output : 5 Method 5 min read Like