Python Program to Find Smallest or Minimum of n Numbers

20-Oct-2022

.

Admin

Python Program to Find Smallest or Minimum of n Numbers

Hi Dev,

Are you looking for example of Python Program to Find Smallest or Minimum of n Numbers. you will learn Find Smallest Number in a List With Code Examples. We will look at example of Python Number min() Method. I would like to share with you smallest element in the list python. Let's get started with How to find the smallest number in a list in Python.

The objective of this Python post, you will see various Python programs that cover the following:

Now let’s see each one by one:

Example 1: 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: 4

Enter number 8

Enter number 12

Enter number 3

Enter number 9

Minimum element in the list is : 3

Example 2: Python program to find smallest of n numbers without using min

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: 3

Enter number 12

Enter number 15

Enter number 11

Minimum element in the list is : 11

I hope it can help you...

#Python