The computation of min and max value is a quite common utility in any programming domain be it development or any other field that includes any programming constructs. Sometimes, data can come in the format of tuples and min and max operations have to be performed in them. Let’s discuss certain ways in which this is handled.
Method #1 : Using
In this method, we use the python inbuilt
max functions to perform the task of getting the minimum and maximum value of a particular element position.
The original list is : [(2, 3), (4, 7), (8, 11), (3, 6)] The min and max of index 1 : (2, 8) The min and max of index 2 : (3, 11)
Method #2 : Using
map() + zip()
This is the more elegant way to perform this particular task. In this task we use
map function to link the elements to the
zip functions that accumulates to perform the functionality of min function or max function.
The original list is : [(2, 3), (4, 7), (8, 11), (3, 6)] The indices wise maximum number : [8, 11] The indices wise minimum number : [2, 3]
- Python | Remove tuples having duplicate first value from given list of tuples
- Python | Remove tuples from list of tuples if greater than n
- Python | Find the tuples containing the given element from a list of tuples
- Python | Count tuples occurrence in list of tuples
- Python program to create a list of tuples from given list having number and its cube in each tuple
- Python | Convert list of tuples to list of strings
- Python | Convert list of tuples to list of list
- Python | Convert list of tuples into list
- Python | Update a list of tuples using another list
- Python | Group tuples in list with same first value
- Python | Unzip a list of tuples
- Python | Linear search on list or tuples
- Python | Selective value selection in list of tuples
- Python | Position Summation in List of Tuples
- Python | Finding frequency in list of tuples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.