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

Hello everybody, this is a Python program which finds out the smallest and largest number in the list.

Here we use 2 predefined functions min() and max() which check for the smallest and largest number in a list respectively.

Program on Github

Largest and Smallest in a list – Code Visualization

Task :

To find largest and smallest number in a list.

Approach :

  • Read input number asking for length of the list using input() or raw_input().
  • Initialise an empty list lst = [].
  • Read each number using a for loop.
  • In the for loop append each number to the list.
  • Now we use predefined function max() to find the largest element in a list.
  • Similarly we use another predefined function min() to find the smallest element in a list.

Program on Github

Program :

Output :

Smallest and Largest element in list - programminginpython.com
Smallest and Largest number in list – programminginpython.com

Program on Github

One Comment

Leave a Reply