Python math.fsum() Methode
Beispiel
Geben Sie die Summe aller Elemente zurück:
# Import math Library
import math
# Print the sum of all items
print(math.fsum([1,
2, 3, 4, 5]))
print(math.fsum([100, 400, 340, 500]))
print(math.fsum([1.7,
0.3, 1.5, 4.5]))
Definition und Verwendung
Die math.fsum()
Methode gibt die Summe aller Elemente in beliebigen Iterablen (Tupel, Arrays, Listen usw.) zurück.
Syntax
math.fsum(iterable)
Parameterwerte
Parameter | Description |
---|---|
iterable | Required. The list, tuple, array to sum. If the iterable is not numbers, it returns a TypeError |
Technische Details
Rückgabewert: | Ein float Wert, der die Summe aller Elemente in der Iterable darstellt |
---|---|
Python-Version: | 2.6 |