[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.
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
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
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
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
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
Top answer 1 of 2
2
One way to reliably get the limits of floating point formats is to construct the values from their binary representation with struct.
import struct
FLOAT_MAX = struct.unpack('>f', b'\x7f\x7f\xff\xff')
FLOAT_MIN = struct.unpack('>f', b'\xff\x7f\xff\xff')
MAX_DOUBLE = struct.unpack('>d', b'\x7f\xef\xff\xff\xff\xff\xff\xff')
MIN_DOUBLE = struct.unpack('>d', b'\xff\xef\xff\xff\xff\xff\xff\xff')
2 of 2
-1
Found a solution like below after referring this
DOUBLE_MAX = 1.7976931348623158E+308 # 64 bit floating point max value
DOUBLE_MIN = 2.2250738585072014E-308 # 64 bit floating point max value
def is_double(value):
return DOUBLE_MIN <= value <= DOUBLE_MAX
FLOAT_MAX = 3.402823466E+38 # 32 bit floating point max value
FLOAT_MIN = 1.175494351E-38 # 32 bit floating point max value
def is_float(value):
return FLOAT_MIN <= value <= FLOAT_MAX
is_float(123e20)
is_double(123e20)
is_float(123e203)
is_double(123e203)
is_float(123e2030)
is_double(123e2030)
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....
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.
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.