Python/ref math fsum
来自菜鸟教程
<languages />
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]))
定义和用法
The
math.fsum()
方法返回所有可迭代项(元组,数组,列表等)的总和。
句法
math.fsum(iterable)
参数值
| 参数 | 描述 |
|---|---|
| iterable | 需要。列表,元组,要求和的数组。如果iterable不是数字,则返回TypeError |
技术细节
| 返回值: | A
|
| Python版本: | 2.6 |