Python | fsum () function



Syntax :

 maths.fsum (iterable) 

Parameter :

  iterable:  Here we pass some value which is iterable like arrays, list. 

the sum of some range, array, list.

Return type:

 The function return a floating point number. 

Code demonstrating fsum () :

# Python code to demonstrate usage
# math.fsum () functions

 
# fsum () is in the 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))

Exit:

 45.0 11.0 7.99