طريقة Python math.fsum ()
مثال
إرجاع مجموع كل العناصر:
# 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]))
التعريف والاستخدام
تُرجع math.fsum()
الطريقة مجموع كل العناصر في أي تكرارات (مجموعات ، مصفوفات ، قوائم ، إلخ).
بناء الجملة
math.fsum(iterable)
قيمه المعامل
Parameter | Description |
---|---|
iterable | Required. The list, tuple, array to sum. If the iterable is not numbers, it returns a TypeError |
تفاصيل تقنية
قيمة الإرجاع: | قيمة float تمثل مجموع كل العناصر الموجودة في العنصر القابل للتكرار |
---|---|
نسخة بايثون: | 2.6 |