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 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 Like