5. Problem to find minimum and maximum elements from a list

In this program, we will take a user input as a list and find the minimum and maximum elements from it with the help of the below-given steps.

Minimum and maximum element in list:

Method 1 : Sorting and indexing

Steps to solve the program
  1. Take a list as input.
  2. Sort the list using Sort().
  3. Print the maximum value i.e. element with -1 index.
  4. Print the minimum value i.e. element with 0 index.

Output :

Minimum and maximum element in list:

Method 2 : Using in-built function

Steps to solve the program
  1. Take a list as input.
  2. Print the maximum value using max().
  3. Print the minimum value using min().

Output :

Related Articles

Product of all elements

 Differentiate even and odd elements

Leave a Comment