Find max and min in a list Python

Find max and min in a list python : In this tutorial, we will learn how to find the maximum and the minimum numbers in the python programming language using list. The list in python language will hold the items of different data types. The items are separated by comma and placed inside the square brackets. The index of any item will start with 0 and we can access item by using this index. The numbering of index starts with 0 then 1 for second element and so on. The program below will show how to remove the maximum and minimum numbers of the list. The numbers are entered by the users in list one by one and read program. The python programming language is simple and has a simple code to find out the maximum and minimum value.
Now min() function is used in program to find out minimum value in the program.
Then max() function is used to find the maximum value in the program.
The index () is used to find out the index of the element.
In the c, c++ the program allows 2 arguments called as the float, char which are a limited bit in python there are no arguments and hold many elements as argument to support the string.

Max ():-

The function used to compute the maximum values which are passed in argument and lexicographically if strings are passes as arguments.
Parameters:-
List:-The list from which the maximum value element is returned.
Return value:-
The method will return the element from the list with the maximum value.
Syntax:-
max(list)
Program:-
Python program to find the largest number
#number in a list
#List of numbers
list1= [11, 22, 33, 44, 55]
#printing the maximum element
print(“maximum element is:” max (list1))

Output:-
Maximum element is: 55

 

Program to take the input from the user and find the maximum value:-

list= []
num=int (input (‘How many numbers :’))
for n in range (num):
numbers=int (input (‘Enter number’))
list.append (numbers)
print(“maximum element in the list is:” max (list))
Output:-
How many numbers: 5
Enter number 11
Enter number 15
Enter number 17
Enter number 19
Enter number 20
Maximum element in the list is: 11

Min():-

The function used to compute the minimum values which are passed in argument and lexicographically if strings are passed as arguments.
Parameters:-
List:-The list from which the minimum value element is returned.
Return value:-
The method will return the element from the list with the minimum value.
Syntax:-
min(list)
Program:-
#python program to find the smallest number in a list
#list of numbers
list1= [11, 22, 33, 44, 55]
#print the minimum element
print(“Minimum element is:” min (list1))
Output:-
Minimum element is: 11

Program to take the input from the user and find the minimum value:-

list= []
num=int (input (‘How many numbers :’))
for n in range (num):
numbers=int (input (‘Enter number’))
list.append (numbers)
print(“minimum element in the list is:” min (list))

 

Output:-
How many numbers: 5
Enter number 11
Enter number 15
Enter number 17
Enter number 19
Enter number 20
Minimum element in the list is: 11

Additional Services : Refurbished Laptops Sales, Python Classes, Share Market Classes And SEO Freelancer in Pune, India