>>> LL
[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]
>>> L
[3, 4, 5, 6, 7, 8, 9]
>>> l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>
>>>
>>> sum(L)
42
>>> sum(LL)
121
>>> sum(l)
45
>>> # 以上是求一个python列表的和的例子
...
>>> # 以下测试能不能求一个Pythontumple的和
... >>> t = (1,2,3,4,5,6,7,8,9,20)
>>> t
(1, 2, 3, 4, 5, 6, 7, 8, 9, 20)
>>> sum(t)
65
>>> # 通过测试可知,可以求一个tumple的和
...
>>> # 以下测试能否求一个字典的和
...
>>> d = {'a':1,'b':2, 'c':3}
>>> d
{'a': 1, 'c': 3, 'b': 2}
>>> sum(d)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>> # 可知,求字典的值是不可以的
...
>>>