Saturday, 16 May 2015

Python program to find the largest and smallest element in a list



This is a Python program which finds out the smallest and largest element in the list.Here we use 2 functions min() and max() to check for the smallest and largest element respectively.




PROGRAM :
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 :", max(lst), "\nMinumim element in the list is :", min(lst))


OUTPUT : 
Python - Largest and Smallest element in a list
 

Similar Programs : 
C program to find the largest element in an array
C program to find the smallest element in an array
Cpp program to find the largest element in an array
Cpp program to find the smallest element in an array
Java program to find the largest  element in an array
Java program to find the smallest element in an array