[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
Stack Overflow
stackoverflow.com › questions › 3477283 › what-is-the-maximum-float-in-python
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. python · floating-point · max · long-integer · Share · Improve this question · Follow · edited Mar 9, 2024 at 21:00 ·
Finding max value in a series of floats
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 ... More on discuss.python.org
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 get max value of np.float32?
The maximum value of a float32 is infinity. More on reddit.com
floating point - Python: Return max float instead of infs? - Stack Overflow
I could put in checks for every time an inf might pop up, or wrap each calculation in a function that rounds inf down to the desired float. More on stackoverflow.com
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 to: 10.56 12.35 11.35 etc.
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 - The maximum float value 1.7976931348623157e+308 uses scientific notation.
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.
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 - An example input would be the initiation of a variable, and the desired output is that this variable holds the largest possible float value that Python can handle. The most straightforward way to set a float to the maximum value in Python is by using float('inf'), which creates a floating-point ...
Berkeley
pythonnumericalmethods.studentorg.berkeley.edu › notebooks › chapter09.02-Floating-Point-Numbers.html
Floating Point Numbers — Python Numerical Methods
The Python float does not have sufficient precision to store the + 2 for sys.float_info.max, therefore, the operations is essentially equivalent to add zero.
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.
Iditect
iditect.com › faq › python › what-is-the-maximum-float-in-python.html
What is the maximum float in Python?
Running this code will print the maximum finite float value, which is typically 1.8 x 10^308 on most Python implementations. Keep in mind that this value may vary slightly depending on the platform and Python version you are using.
Reddit
reddit.com › r/learnpython › how do i get max value of np.float32?
How do I get max value of np.float32? : r/learnpython
March 31, 2021 - The maximum value of a float32 is infinity. ... You're not wrong Walter. You're just an asshole. ... Not in theory, there is a literal value of infinity that can be encoded as a float. ... I'm 37 and looking for a complete career change. ... Started MOOC 2026 Python Programming today Module ...
Pythontic
pythontic.com › containers › list › max
max() function of list in Python | Pythontic.com
The max() function returns the largest of the elements present in a Python list. The example creates a list of floating point numbers and prints the largest of them.
Top answer 1 of 2
3
You can use a decorator:
import sys
def noInf(f):
def wrapped(*args, **kwargs):
res = f(*args, **kwargs)
if res == float('inf'):
return sys.float_info.max
return res
return wrapped
@noInf
def myMult(x, y):
return x*y
print(myMult(sys.float_info.max, 2)) # prints 1.79769313486e+308
2 of 2
2
I don't know about 'replacing' infinity value, but what about using min()?
Something like (assuming x yields your value):
return min ( [ x, sys.float_info.max ] )
Real Python
realpython.com › lessons › find-maximum-number-solution
Find the Maximum Number (Solution) (Video) – Real Python
02:45 The parameter that we are interested in is called float_info, and it shows a number of low-level details about the floating-point data type in Python, including max_10_exp, which is equal to 308 that we found manually.
Published: November 7, 2023
Codemia
codemia.io › home › knowledge hub › what is the maximum float in python?
What is the maximum float in Python? | Codemia
September 24, 2025 - Using float for financial or high-precision decimal calculations. The maximum finite Python float is available as sys.float_info.max.