This function is used to calculate the maximum of values passed in its argument and the lexicographically largest value if strings are passed as arguments.
Syntax: max (a, b, c, ..) Parameters: a, b, c, ..: similar type of data. Return Value: Returns the maximum of all the arguments. Exceptions: Returns TypeError when conflicting types are compared.
Maximum of 4,12,43.3,19 and 100 is: 100
This function is used to calculate the minimum of values passed in its argument, and the lexicographically smallest value if passed as arguments lines.
Syntax: min (a, b, c, ..) Parameters: a, b, c, ..: similar type of data. Return Value: Returns the minimum of all the arguments. Exceptions: Returns TypeError when conflicting types are compared.
Minimum of 4,12,43.3,19 and 100 is : 4
1. TypeError: These functions throw a TypeError when comparing conflicting data types .
| tr> |
Minimum of 4,12,43.3,19 and Python.Engineering is:
Traceback (most recent call last): File "/home/b5da1d7f834a267f94fbbefe1b31a83c.py", line 7, in print (min (4,12,43.3,19, "Python.Engineering ")) TypeError: unorderable types: str () & lt; int ()
One of the practical uses among many is finding the lexicographically largest and smallest lines, ie The line that appears first or last in the dictionary.
The word occurring 1st in dict. among given is: algorithm The word occurring last in dict. among given is: programming
This article courtesy of Manjeet Singh . If you are as Python.Engineering and would like to contribute, you can also write an article with contribute.python.engineering or post the article [email protected] See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you'd like to share more information on the topic discussed above.