[image] James Marshall: The code for finding the average was given to me, and the exercise was to add code to find the maximum. The existing code was, presumably, provided as a model that you are expected to understand in order to see some basic tools available to you, so that you can then us… Answer from kknechtel on discuss.python.org
🌐
Note.nkmk.me
note.nkmk.me › home › python
Maximum and Minimum float Values in Python | note.nkmk.me
August 11, 2023 - See the official documentation for a list of items and their explanations. Each item corresponds to a floating point constant defined in the standard header file float.h in the C language. You can obtain the maximum representable float value with sys.float_info.max.
🌐
Finxter
blog.finxter.com › home › learn python blog › integer and float maximums in python’s max() function
Integer and Float Maximums in Python's Max() Function - Be on the Right Side of Change
September 15, 2019 - print(max([5, 10, 10.0])) # 10 print(max([5, 10.0, 10])) # 10.0 · It simply returns the highest value in an iterable. Note that many advanced coders worry that we cannot compare an int with a float because of limited floating point precision because they know the following example: print(0.3+0.3+0.3 == 0.9) # False print(0.3+0.3+0.3) # 0.8999999999999999 · This is not an issue when comparing integers with “integer-like” floats. Python floats can represent integers perfectly fine.
Discussions

float and double max value check in python - Stack Overflow
Since python supports large numbers, I would like to do validate the given number in within the range of float(32 bit floating point representation) or double(64 bit floating point representation)? How can I achieve it? def is_int(x): int_max_value = 2^31 - 1 int_min_value = -2^31 if int_min_value ... More on stackoverflow.com
🌐 stackoverflow.com
python - How do I find the maximum (larger, greater) of 2 numbers? - Stack Overflow
I have two variables value and run: value = -9999 run = problem.getscore() How can I find out which one is greater, and get the greater value? See also Find the greatest (largest, maximum) number... More on stackoverflow.com
🌐 stackoverflow.com
September 28, 2013
floating point - What is the maximum float in Python? - Stack Overflow
The maximum integer in Python 2 is available by calling sys.maxint. What is the maximum float or long in Python? See also: Maximum and Minimum values for ints. More on stackoverflow.com
🌐 stackoverflow.com
how to get the max value if that is a float?
The error message sounds like you are giving max() function only 1 number... It can't find the max if you only give it one number... >>> max([1.5, 2763.2]) 2763.2 >>> max(1.5) Traceback (most recent call last): File "", line 1, in TypeError: 'float' object is not iterable More on reddit.com
🌐 r/learnpython
2
2
December 6, 2022
People also ask

How do I find the maximum of two numbers in Python?
Call max(first, second) when both values are comparable and the result should be the larger value.
🌐
pythonpool.com
pythonpool.com › home › tutorials › how to find the maximum of two numbers in python
4 Ways in Python to Get Max of Two Numbers
Why does max raise a TypeError?
The values may not be mutually comparable, or the input may contain a type that does not define the ordering you expect.
🌐
pythonpool.com
pythonpool.com › home › tutorials › how to find the maximum of two numbers in python
4 Ways in Python to Get Max of Two Numbers
What happens when the values are equal?
max returns the equal value, while a conditional expression can choose the first or second object deliberately.
🌐
pythonpool.com
pythonpool.com › home › tutorials › how to find the maximum of two numbers in python
4 Ways in Python to Get Max of Two Numbers
🌐
Python.org
discuss.python.org › python help
Finding max value in a series of floats - Python Help - Discussions on Python.org
April 15, 2024 - I am trying to write code that takes a row of floats from a csv file, representing the average temperature in a given month over the course of 70 years, and returns the highest float value of them all. When I print the variable holding the float values, in this case val, I get something similar ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › maximum-of-two-numbers-in-python
Find the Maximum of two numbers in Python - GeeksforGeeks
Let's explore different ways to find the larger of two numbers. max() function compares two or more values and returns the largest one.
Published: May 18, 2026
🌐
Python Pool
pythonpool.com › home › tutorials › how to find the maximum of two numbers in python
4 Ways in Python to Get Max of Two Numbers
July 13, 2026 - max(a, b) returns the larger of two comparable values. User input arrives as strings. Convert values to numbers before comparing them; otherwise, Python compares text lexicographically, which can produce surprising results.
🌐
Pyschool
pyschool.ai › home › curriculum › find maximum of two
Find Maximum of Two Python Practice Lesson | PySchool.ai
March 15, 2026 - Two numbers a and b are provided as function arguments: find_max(a, b). ... Return the larger number (int or float).
Find elsewhere
🌐
Berkeley
pythonnumericalmethods.studentorg.berkeley.edu › notebooks › chapter09.02-Floating-Point-Numbers.html
Floating Point Numbers — Python Numerical Methods
Numbers that are larger than the ... in underflow, and Python handles this case by assigning the result to 0. TRY IT! Show that adding the maximum 64 bits float number with 2 results in the same number....
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › find maximum float value in python
Find Maximum Float Value in Python - Spark By {Examples}
May 31, 2024 - How to find the maximum float value in Python? You can find the maximum value of the float data type using the sys.float_info module or the finfo()
🌐
Stack Overflow
stackoverflow.com › questions › 3477283 › what-is-the-maximum-float-in-python
floating point - What is the maximum float in Python? - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... The maximum integer in Python 2 is available by calling sys.maxint.
🌐
Reddit
reddit.com › r/learnpython › how to get the max value if that is a float?
r/learnpython on Reddit: how to get the max value if that is a float?
December 6, 2022 -

Hi, I have calculated some values and now need the program to print which is the largest. The problem is that these numbers are floats and I get an error: TypeError: 'float' object is not iterable when using the max function. And I can't change it to int for example, because I need to include numbers after the comma. I would be really grateful if someone could help me.

🌐
GeeksforGeeks
geeksforgeeks.org › python-min-max-value-in-float-string-list
Python | Min/Max value in float string list - GeeksforGeeks
April 8, 2023 - Method 1: Using min()/max() + float() This problem can be solved using the min or max function in which we first convert the strings into float and then pass this logic in functions in respective min/max function.
🌐
GeeksforGeeks
geeksforgeeks.org › maximum-of-two-numbers-in-python
Find Maximum of two numbers in Python - GeeksforGeeks
Let's explore different ways to do this efficiently.Using max()max() function is the most opt ... The factorial of a number is the product of all positive integers less than or equal to that number.
Published: May 9, 2025
🌐
Tutorialspoint
tutorialspoint.com › python › number_max.htm
Python max() Function
The Python max() function is used to retrieve the largest element from the specified iterable. Finding the maximum of two given numbers is one of the usual calculations we perform.
🌐
TutorialsPoint
tutorialspoint.com › article › what-is-the-maximum-value-of-float-in-python
What is the maximum value of float in Python?
March 24, 2026 - In Python, floating-point numbers are implemented using double-precision, i.e., 64-bit format, as per the IEEE 754 standard. These floats have a finite range and precision. The maximum value that a float can represent depends on the platform, but can be accessed using the sys.float_info attribute.
🌐
DEV Community
dev.to › frankkk › python-tips-floatinf-269h
Python Tips- Maximum Value float('inf') - DEV Community
February 3, 2024 - For the float, we max value is sys.float_info.max. for the integer, we can use the value sys.maxsize. But Integer (int) has no max limit in Python 3, from the source code in C language, the int object is defined variable size, that is why it has no max limit.
🌐
Python Examples
pythonexamples.org › python-program-maximum-of-two-numbers
Python - Find Maximum of Two Numbers
To find the maximum of given two numbers in Python, call max() builtin function and pass the two numbers as arguments.
🌐
Finxter
blog.finxter.com › setting-a-python-float-to-its-maximum-possible-value
Setting a Python Float to Its Maximum Possible Value – Be on the Right Side of Change
February 25, 2024 - Python’s sys module provides a float_info object, which has a max attribute containing the largest representable positive finite float. It is a concrete value close to the upper boundary of a float’s range in Python.
🌐
Pythontic
pythontic.com › containers › list › max
max() function of list in Python | Pythontic.com
The max() function returns the maximum of the elements present in a Python list.