Home >>Python math Module >Python math.fsum() Method
Python math.fsum() method in python is used to returns sum in float of all values and , it accepts an iterable object like tuple, lists, arrays, etc (that should contain numbers in either integers or floats) as a floating point number.
Syntax:math.fsum(iterable)
Parameter | Description |
---|---|
Iterable | It is required a number to return floats of values |
import math
x = (2, 4, 6, 8, 10)
print(math.fsum(x))
import math
v = range(10)
w = [5, 10, 15, 20, 25]
x = [5.05, 10, 15.06, 20, 25.07]
y = [5.25, 20.15]
z = (5, 14, 10.03, 25.05)
print("fsum(v): ", math.fsum(v))
print("fsum(w): ", math.fsum(w))
print("fsum(x): ", math.fsum(x))
print("fsum(y): ", math.fsum(y))
print("fsum(z): ", math.fsum(z))