Python math.fsum() Method
Example
Return the sum of all items in a tuple:
# Import math Library
import math
# Add items in a tuple
a =
(1, 2, 3, 4, 5)
# Print the sum of all items
print(math.fsum(a))
Try it Yourself »
Definition and Usage
The math.fsum() method returns the sum of all
items in an iterable (tuples, arrays, lists, etc.), as a floating point number.
Syntax
math.fsum(iterable)
Parameter Values
| Parameter | Description |
|---|---|
| iterable | Required. The sequence to sum. If the sequence is not a number, it returns a TypeError |
Technical Details
| Return Value: | A float value, representing the sum of all
items in the iterable |
|---|---|
| Python Version: | 2.6 |


