[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. ... See also: Maximum and Minimum values for ints.
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
import sys def noInf(f): def ... y): return x*y print(myMult(sys.float_info.max, 2)) # prints 1.79769313486e+308 ... Sign up to request clarification or add additional context in comments. ... I don't know about 'replacing' infinity value, but what about using min... More on stackoverflow.com
Help understanding this 'float' object is not callable error
That's not what I get, which is TypeError: 'float' object is not subscriptable on the line where you assign to r. The result of m.e**(2*x) is a number, not a list and you can't use [] with a number. y[x+h] is nonsense. It looks like you're thinking of these assignment statements as if they were equations, but they're not. (That's not an uncommon mistake, because programming often borrows concepts and notation from mathematics, but not in this case.) For example, if you wrote y = x**4, that means "take the current value of x, raise is to the fourth power, and assign the result to y." It does not mean that y is now a function that can be called to raise any x to the fourth power, as would be the case if you were in a mathematics class and wrote y(x) = x4 on the board. If you want that, you need to explicitly define y as a function (i.e. with def or a lambda.) More on reddit.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 ...
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 ...
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 ...
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 ] )
w3resource
w3resource.com โบ python-exercises โบ python-basic-exercise-123.php
Python: Determine the largest and smallest integers, longs, floats - w3resource
May 17, 2025 - Float value information: sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250 738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2 , rounds=1) Integer ...
Codemia
codemia.io โบ home โบ knowledge hub โบ what is the maximum float in python?
What is the maximum float in Python? | Codemia
September 24, 2025 - Python float values are usually implemented as IEEE 754 double-precision numbers. That gives a large but finite range, so there is a maximum representable finite float before arithmetic overflows to infinity.
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.
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.
Linux Hint
linuxhint.com โบ python-max-function
Linux Hint โ Linux Hint
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use