1 / 24

LogMeIn

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

hope
Télécharger la présentation

LogMeIn

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LogMeIn.com $Free $70/yr

  2. iTunesU

  3. 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

  4. 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

  5. Tuple methods Creation Tuple with one item Methods (there are not any public methods)

  6. Like strings, tuples are immutable Immutable = cannot be changed in-place

  7. Tuples in format statements

  8. Tuples in return statements

  9. 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

  10. List methods Creation Methods

  11. Lists are mutable Mutable = can be changed in-place

  12. Built-in list methods Adding to • append( ) • extend( ) • insert( ) Removing from • remove( ) • pop( ) Searching • index( ) • count( ) Changing order • sort( ) • reverse( )

  13. 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

  14. Creation Dict methods Can not have duplicate keys in a dictionary !!! Methods

  15. 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)

  16. Built-in dict methods Clearing • clear( ) • pop( ), popitem( ) Searching • has_key( ) • get( ) Converting • items( ) • keys( ) • values( ) Iterating (over very large collections) • iteritems( ) • iterkeys( ) • itervalues( )

  17. Other ways to create Dictionaries

  18. Sorting Dictionaries, not. • Dictionaries are automatically sorted when they are built to optimize access by key. User has no control.

  19. Dictionary conversions

  20. Syntax synopsis

  21. Great reference!

  22. 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

  23. Engrish packaging I don’t want to meet the woman who uses this.

More Related