Python matematik.fsum() Yöntem
Örnek
Tüm öğelerin toplamını döndür:
# 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]))
Tanım ve Kullanım
Yöntem math.fsum()
, herhangi bir yinelenebilir (tuples, diziler, listeler, vb.) içindeki tüm öğelerin toplamını döndürür.
Sözdizimi
math.fsum(iterable)
Parametre Değerleri
Parameter | Description |
---|---|
iterable | Required. The list, tuple, array to sum. If the iterable is not numbers, it returns a TypeError |
Teknik detaylar
Geri dönüş değeri: | float Yinelenebilirdeki tüm öğelerin toplamını temsil eden bir değer |
---|---|
Python Sürümü: | 2.6 |