Articles

Program to find maximum and minimum element from list in Python

Program to find maximum and minimum element from list in Python


In this python programming tutorial, we are going to learn:

  • python program to find maximum and minimum value in the list

python program to find maximum and minimum value in the list

The python program to find maximum and minimum value in the list is as follows:

 

# Owner : TutorialsInhand Author : Devjeet Roy

marks=[78,56,98,39,55,91,72]

max_number =  0
min_number = 100

for i in marks:
    if i > max_number:
        max_number = i
    if i < min_number:
        min_number = i

print("Highest marks:",max_number)
print("Lowest marks:", min_number)

The output of the python program to find maximum and minimum value in the list is as follows:

 

PS C:\Users\DEVJEET\Desktop\tutorialsInHand> python code.py
Highest marks: 98
Lowest marks: 39

Few important tips about the program

1. We assign 0 to the max_number and 100 to the min_number variables. As the iteration continues they continuously compare and reassign themselves accordingly.

2. Python provides max() and min() methods which takes the name of the list as its argument and returns the maximum and minimum number from within a list.

 

Write a python program to find biggest and smallest elements from list snapshot:

maximum and the minimum element from a given list

Thus we have learned to python program to find maximum element in a list and also how to find minimum value of a list in python.


Python Programs

Would you like to see your article here on tutorialsinhand. Join Write4Us program by tutorialsinhand.com

About the Author
Devjeet Roy
Full Stack Web Developer & Blockchain Enthusiast
Page Views :    Published Date : Jun 16,2022  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!