Python Program to Find Smallest or Minimum of n Numbers

Python program to find minimum or smallest of n numbers;Through this tutorial, i am going to show you how to find minimum or smallest number of n number or given list.

In this tutorial, i will write two python program to find minimum or smallest number from list or given n numbers.

Python Program to Find Smallest/Minimum of n Numbers

  • Python program to find smallest of n numbers using min
  • Python program to find smallest of n numbers using function

Python program to find smallest of n numbers using min

lst = []
num = int(input('How many numbers: '))
for n in range(num):
    numbers = int(input('Enter number '))
    lst.append(numbers)
    
print("Maximum element in the list is :", min(lst))

Output

How many numbers:  5
Enter number  6
Enter number  4
Enter number  2
Enter number  8
Enter number  9
Minimum element in the list is : 2

Python program to find smallest of n numbers using function

def find_min( list ):
    min = list[ 0 ]
    for a in list:
        if a < min:
            min = a
    return min
num = int(input('How many numbers: '))
lst = []
for n in range(num):
    numbers = int(input('Enter number '))
    lst.append(numbers)
    
print("Minimum element in the list is :", find_min(lst))

Output

How many numbers:  4
Enter number  1
Enter number  5
Enter number  8
Enter number  9
Minimum element in the list is : 1

Recommended Python Tutorials

Recommended:-Python Map() Method

Be First to Comment

Leave a Reply

Your email address will not be published.