BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Python Program to Find Smallest Number in a List

Last Updated: June 9, 2019 by Chaitanya Singh | Filed Under: Python Examples

In this tutorial, we will see various Python programs to find the smallest number in a List. For example, if the list is [15, 20, 10, 16] then the program should display number 10 as the output (the smallest number in the given list).

Example 1: Finding smallest number in a list using sort() method

In the following program, we are finding the smallest number in the given list using sort() function. The sort() function sorts the given list in ascending order. We are then displaying the first element of the list, which is the smallest number of the sorted list.

# Python program to find smallest number in a list

# Given list of numbers
lis = [89, 100, 35, 16, 99]

# sorting the given list "lis"
# sort() function sorts the list in ascending order
lis.sort()

# Displaying the first element of the list
# which is the smallest number in the sorted list
print("Smallest number in the list is:", lis[0])

Output:
Python Program to Find Smallest Number in a List

Example 2: Finding smallest number in a list using min() method

In the following program we are finding the smallest number of the list using min() method. The min() method returns the smallest element of the list.

# Python program to find smallest number in the
# given list using min() method

# Given list of numbers
lis = [9, 100, 3, 16, 60]

# min() method returns the smallest element of the list
print("Smallest number of the list is:", min(lis))

Output:
Finding smallest number in a list using min() method

Example 3: Finding smallest number in a list, where list is provided by user

In the following program we are finding the smallest number in the user provided list, user is asked to enter the number of elements to put in a list. User then enters the elements of the list one by one, each input element is appended to the list using append() method. At the end of the program, the smallest number of the list is displayed using min() method.

# creating empty list
lis = []

# user enters the number of elements to put in list
count = int(input('How many numbers? '))

# iterating till count to append all input elements in list
for n in range(count):
    number = int(input('Enter number: '))
    lis.append(number)

# displaying smallest element
print("Smallest element of the list is :", min(lis))

Output:
Smallest Number in user provided list

Related Python Examples

  1. Python program to find largest number in a list
  2. Python program to find largest among three numbers
  3. Python program to convert decimal to hexadecimal
  4. Python program to swap two numbers

Top Related Articles:

  1. Python Program to Find Largest among Three Numbers
  2. Python Program to Check if a Number is Positive Negative or Zero
  3. Python Program to Find Factorial of Number
  4. Python Program to Convert Celsius To Fahrenheit and Vice Versa
  5. Python Program to Convert Decimal to Hexadecimal

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap