```python
def sum_function(iterable, start=0):
return sum(iterable, start)
其中,`iterable`是一个可迭代对象,如列表、元组、集合等,`start`是可选参数,表示求和的起始值,默认值为0。
例如,如果你想计算从1到10的所有整数之和,你可以这样使用自定义的`sum_function`:
```python
numbers = range(1, 11)
total = sum_function(numbers)
print(total) 输出:55