import math
print(type(math.fsum([4,6,1]))) # <class 'float'>
print(type(math.fsum([1.4,6,1]))) # <class 'float'>
Difference between fsum() and sum()
fsum() is included in Python math module so we have to import it before using. Where as sum() is part of built in functions of core Python so no need to import any library.
fsum() returns always float dtype. However sum() returns the same dtype of input number.