***Welcome to ashrafedu.blogspot.com * * * This website is maintained by ASHRAF***

Tuesday, June 15, 2021

The min and max Functions

Python
has two built-in functions named min and max that work with sequences.



The
min function accepts a sequence, such as a list, as an argument and returns the
item that has the lowest value in the sequence.



The
max function accepts a sequence, such as a list, as an argument and returns the
item that has the highest value in the sequence.



my_list
= [5, 4, 3, 2, 50, 40, 30]



print('The
lowest value is', min(my_list))



print('The
highest value is', max(my_list))

No comments:

Post a Comment