260 likes | 419 Views
LogMeIn.com. $Free. $70/yr. iTunesU. Python Container Types. Dictionary elements stored as key,value pairs & accessed by key object d[key]. Sequence elements stored in order & accessed by index number s[num]. Python container types. Python Container Types. Dictionary elements
E N D
LogMeIn.com $Free $70/yr
Python Container Types Dictionary elements stored as key,value pairs & accessed by key object d[key] Sequence elements stored in order & accessed by index numbers[num] Python container types
Python Container Types Dictionary elements stored as key,value pairs & accessed by key object d[key] Sequence elements stored in order & accessed by index numbers[num] Python container types
Tuple methods Creation Tuple with one item Methods (there are not any public methods)
Like strings, tuples are immutable Immutable = cannot be changed in-place
Python Container Types Dictionary elements stored as key,value pairs & accessed by key object d[key] Sequence elements stored in order & accessed by index numbers[num] Python container types
List methods Creation Methods
Lists are mutable Mutable = can be changed in-place
Built-in list methods Adding to • append( ) • extend( ) • insert( ) Removing from • remove( ) • pop( ) Searching • index( ) • count( ) Changing order • sort( ) • reverse( )
Python Container Types Dictionary elements stored as key,value pairs & accessed by key object d[key] Sequence elements stored in order & accessed by index numbers[num] Python container types
Creation Dict methods Can not have duplicate keys in a dictionary !!! Methods
Dictionary operations • Adding elements • Deleting elements • Accessing elements • Updating elements • Finding size Items in collection are fetched by key not by index number (dict is a mapping not a sequence) Keys can be string, number, or tuple (the immutables)
Built-in dict methods Clearing • clear( ) • pop( ), popitem( ) Searching • has_key( ) • get( ) Converting • items( ) • keys( ) • values( ) Iterating (over very large collections) • iteritems( ) • iterkeys( ) • itervalues( )
Sorting Dictionaries, not. • Dictionaries are automatically sorted when they are built to optimize access by key. User has no control.
Python Container Types Dictionary elements stored as key,value pairs & accessed by key object d[key] Sequence elements stored in order & accessed by index numbers[num] Python container types
Engrish packaging I don’t want to meet the woman who uses this.