min() and max()

noun

say it: “MIN and MAKS” /mɪn ænd mæks/

Two built-in Python functions: min() gives the smallest value from a list or from several values, and max() gives the largest.

What do min() and max() do?

min() gives the smallest value and max() the largest, from a list or from several values.

temperatures = [68, 75, 59, 81]
print(min(temperatures))  # 59
print(max(temperatures))  # 81

In a sentence

  • “min() and max() picked out the coldest and hottest day from the week's temperatures.”
  • “The leaderboard uses max() to find the top score in one line.”

Level: Apprentice · More Python terms at this level

Updated