GeeksforGeeks
geeksforgeeks.org › python › python-max-function
Python - max() function - GeeksforGeeks
July 15, 2025 - Python max() function returns the largest item in an iterable or the largest of two or more arguments.
W3Schools
w3schools.com › python › ref_func_max.asp
Python max() Function
Python Examples Python Compiler ... Q&A Python Training ... The max() function returns the item with the highest value, or the item with the highest value in an iterable....
79-character column limit is a nightmare
Well it is what it is. I used to be hostile to the 79-character limit until I realized that on my widescreen laptop, I could fit two code buffers side-by-side with no wrap or truncation if I did the 79-char limit. Since then I've been converting a lot of code. Here's a couple of tips that have helped me keep the code under 80 characters and not too ugly: Use triple-quoted strings if whitespace doesn't matter (e.g. HTML strings or SQL queries). Define long strings like error messages somewhere else (an include file, as static class members, whatever makes sense). If you've got a long function call or collection that's going to need to be broken up, break after the opening paren/brace/bracket. According to my linter (if not PEP8), you only need to indent 4 spaces if you break after the opening delimter. Otherwise you indent all the way up to the first value. For example: instead of this: some_object.long_method_name("fizz", "buzz", "fozz", "bizz", "quux", 1, "lemon", "spam") this: some_object.long_method_name( "fizz", "buzz", "fozz", "bizz", "quux", 1, "lemon", "spam" ) or even this: some_object.long_method_name( "fizz", "buzz", "fozz", "bizz", "quux", 1, "lemon", "spam" ) I don't know that I've ever gotten to the point of consulting a thesaurus to make my comments shorter; are you dealing with some deeply nested comments? EDIT: can't get the code to line up right on reddit, but you get the idea. More on reddit.com
min() vs 'sort() and then list[0]'
As others have mentioned, min will be quicker. min just has to walk through the list once, whereas sort must do more compares, making it more complex.
However, one case you might want to use sort is when you need more than just the minimum. Eg. you want the 5 smallest items, not just the smallest. Here "sorted(mylist)[:5]" will do the job, but another option to keep in mind is the heapq module, as "heapq.nsmallest(5, mylist)" will often perform better than sort, at least for a small number of items.
How do I find the relative maximum in a function?
Take the derivative and find where it equals zero. Also, do your calculus homework using calculus! But seriously - give us more context. You really can use numpy/scipy to get a derivative, or you can scan the function with some arbitrary input, or you can ask questions we can't answer without proper setup. WHY are you trying to find a local maxima? What inputs do you have? What context is this in? More on reddit.com
How long should a .py file be?
Generally, I don't care about the line count of a module. I group my classes / functions in a way that seems natural. Some modules are only 50 lines long. Others reach the 1000. After all, what difference does pure line count make once it's beyond "more than a couple of screens full"? More on reddit.com
15:22
Starting With Python's min() and max() Functions - YouTube
02:14
How to use Python max() built-in function - YouTube
Python Max() Function #python #coding
16:03
Learn Python min() and max() functions - YouTube
00:46
Mastering the min() and max() Functions in Python - YouTube
00:47
Breaking Math With Python - MAX Function - YouTube
Python Reference
python-reference.readthedocs.io › en › latest › docs › functions › max.html
max — Python Reference (The Right Way) 0.1 documentation
Returns the largest item in an iterable or the largest of two or more arguments · max (collection[, key])
Letpy
letpy.io › handbook › builtins › max
Built-in Python Function max: Documentation, Description, and Examples
key (optional): A key function ... and this argument is not specified, a ValueError is raised. max() identifies and returns the element with the highest value in the specified iterable or among the arguments....
Programiz
programiz.com › python-programming › methods › built-in › max
Python max()
key (optional) - key function where the iterables are passed and comparison is performed based on its return value · default (optional) - default value if the given iterable is empty · max() returns the largest element from an iterable. ... If the items in an iterable are strings, the largest ...
ThePythonGuru
thepythonguru.com › python-builtin-functions › max
Python max() function - ThePythonGuru.com
January 7, 2020 - The max() function returns the largest of the input values.Its syntax is as follows:max(iterable[, default=obj, key=func]) -> value PARAMETER …
Codecademy
codecademy.com › docs › python:numpy › built-in functions › .max()
Python:NumPy | Built-in Functions | .max() | Codecademy
July 2, 2025 - Returns the maximum value of an array or maximum values along a specified axis.
Hyperskill
hyperskill.org › university › python › max-in-python
Python max() Function — Syntax, key Parameter & Examples
August 10, 2026 - The max() function finds the maximum value among elements of an iterable or a series of arguments. It returns the largest item based on the default ordering or a custom ordering specified by the optional key parameter. When used with iterables like lists or tuples, the function compares the ...
ZetCode
zetcode.com › python › max-builtin
Python max Function - Complete Guide
April 11, 2025 - This comprehensive guide explores Python's max function, which returns the largest item in an iterable or among arguments.
Vultr Docs
docs.vultr.com › python › built-in › max()
Python max() - Find Maximum Value
September 27, 2024 - The max() function in Python is a built-in utility that identifies the maximum value among the provided arguments or elements within an iterable.
Jobtensor
jobtensor.com › Tutorial › Python › en › Builtin-Functions-max
Python Built-in max(), Definition, Syntax, Parameters, Examples | jobtensor
The max() function returns the item with the highest value, or the item with the highest value in an iterable.
Python Academy
python-academy.org › functions › max
max — Python Function Reference
A comprehensive guide to Python functions, with examples. Find out how the max function works in Python. Return the largest item in an iterable or the largest of two or more arguments.
Python Tutorial
pythontutorial.net › home › python built-in functions › python max() function
Python max(): Return the Maximum Item
September 15, 2022 - The max() function also accepts an iterable and returns the maximum item of the iterable: ... key is an optional keyword-only argument that specifies the key for comparing the items of the iterable. default is an optional keyword-only argument that specifies a value that the max() returns when ...