About 3,420,000 results
Open links in new tab
  1. Python's min() and max(): Find Smallest and Largest Values

    Jan 18, 2025 · Python’s built-in functions max() and min() allow you to find the largest and smallest values in a dataset. You can use them with iterables, such as lists or tuples, or a series of regular arguments. They can handle numbers, strings, and even dictionaries.

  2. python - Find min, max, and average of a list - Stack Overflow

    how can I find min and max of this list with defining (def) a function. I do not want to use built-in function min. If you want to manually find the minimum as a function: min_value = None. for value in somelist: if not min_value: min_value = value. elif value < …

  3. max() and min() in Python - GeeksforGeeks

    Jun 17, 2021 · This function is used to compute the minimum of the values passed in its argument and lexicographically smallest value if strings are passed as arguments. Syntax : min(a,b,c,.., key,default) Parameters : a,b,c,.. : similar type of data.

  4. Position of maximum and minimum element in a listPython

    Apr 14, 2025 · The easiest way to find the position of the maximum and minimum elements in a list is by using Python’s built-in max() and min() functions along with index(): Python a = [ 3 , 5 , 7 , 2 , 8 , 1 ] mxp = a . index ( max ( a )) mnp = a . index ( min ( a )) print ( mxp ) print ( mnp )

  5. How to Find the Largest and Smallest Numbers in Python? - Python

    Aug 29, 2024 · To find the largest and smallest number in a list in Python, you can use the built-in functions max() and min(). For example, if you have a list numbers = [3, 1, 4, 1, 5, 9, 2], you can find the largest number by calling max(numbers) and …

  6. How can I get the minimum and the maximum element of a list in python

    Jun 5, 2013 · To do this in a single loop, iterate over the list and test each item against the minimum and maximum found so far. float('inf') and float('-inf') (infinity and negative infinity) are good starting points to simplify the logic: if item < minimum: minimum = item. if item > maximum: maximum = item.

  7. List Methods in Python | Set 1 (in, not in, len(), min(), max ...

    Aug 3, 2022 · Maximum and Minimum element in a Set in Python We are given a set and our task is to find the maximum and minimum elements from the given set. For example, if we have a = {3, 1, 7, 5, 9}, the maximum element should be 9, and the minimum element should be 1.

  8. Python Min & Max: Find largest & smallest values (Or with loop)

    Nov 28, 2023 · In Python, there are two powerful functions that allow you to easily find the smallest and largest values in a given dataset or collection. These functions are min () and max (). They can be applied to various data types, including numbers, strings, and more complex objects.

  9. Python max() and min(): Find max and min in Array

    Sep 21, 2023 · Python provides two handy functions, max() and min(), that makes it easy to find the largest (or the smallest) item in any iterable (e.g. list, set or array) of comparable elements. In this beginner-friendly guide, we’ll explore how to use max() and min() effectively.

  10. Python Program to Find Smallest and Largest Number - PYnative

    Mar 31, 2025 · The min() and max() functions are built-in Python functions used to find the smallest and largest values from a given set of numbers, lists, ... The sort() function is a built-in list method in Python that sorts the elements of a list in place, meaning it modifies the original list instead of creating a new one. Syntax: list.sort ...

  11. Some results have been removed
Refresh