Python | fsum() function
fsum() is inbuilt function in Python, used to find sum between some range or an iterable. To use this function we need to import the math library.
Syntax :
maths.fsum( iterable )
Parameter :
iterable : Here we pass some value which is iterable like arrays, list.
Use :
fsum() is used to find the sum of some range, array , list.
Return Type :
The function return a floating point number.
Code demonstrating fsum() :
# Python code to demonstrate use # of math.fsum() function # fsum() is found in math library import math # range(10) print(math.fsum(range(10))) # Integer list arr = [1, 4, 6] print(math.fsum(arr)) # Floating point list arr = [2.5, 2.4, 3.09] print(math.fsum(arr)) |
chevron_right
filter_none
Output :
45.0 11.0 7.99
Recommended Posts:
- sum() function in Python
- Help function in Python
- Python | now() function
- ord() function in Python
- Python | oct() function
- Python | How to get function name ?
- Python | cmp() function
- id() function in Python
- Python | hex() function
- Python | dir() function
- Python map() function
- Python | int() function
- Python | fmod() function
- Python | locals() function
- Python statistics | mean() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



