Doris,2016.6.15,chapter+9

=chapter 9=

note
tuple is an example of a **data structure ** — a mechanism for grouping and organizing data to make it easier to use.

a=(a,b,c,d) a[0]---a a[1]---b a[2]---c

slice:a[:1]---a,b

code format="python" >>> tup = (5,) >>> type(tup)  >>> x = (5) >>> type(x) 

code

packing & no packing a=(a,b,c)packing

each of those in turn can be another tuple, a list, a string, or any other kind of Python value. This property is known as being **heterogeneous **, meaning that it can be composed of elements of different types.

exercise
1. code format="python" def tuple_can_be_arguement(n): return n print(tuple_can_be_arguement(('a','b'))) code 2. tuple a generalization of a pair 3.

pair is a kind of tuple