Lecture12 Trees
1. Box-and-pointer Notation
Lists are represented as a row of index-labeled adjacent boxes, one per element
Each box either contains a primitive value or points to a compound value
eg.
'>>>pairs = [1, 2]
‘>>>nested_list = [ [1, 2], [ ], [ [3, False, None] , [4, lambda: 5 ] ] ]
2. Slicing
3. Processing Container Values
1.sum(iterable[, start]) -> value
解释:Return the sum of an iterable of numbers (NOT strings) plus the value of parameter ‘start’ (which defaults to 0). When the iterable is empty, return start.
>>> sum([2,3,4])
9
>>> sum([2,3],4)
9
>>> sum (['2', '3', '4'])
TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>> sum([2, 3], [4])
TypeError: can only concatenate list (not "int") to list
>>> [2, 3]+[4]+ []
[2, 3,