Outline for December 3, 2012

Reading: § 18
Assignment Due: Friday, December 7, 2012 at 11:55 PM


  1. Review: dictionary
    1. Collection of key-value pairs
  2. Dictionary lookup [morse.py]
  3. Example: word frequency count
    1. Unsorted [wfc-1.py]
    2. Sorted alphabetically [wfc-2.py]
    3. Sorted alphabetically, but dictionary order (note key=str.lower() in sorted [wfc-2a.py]
    4. Sorted by frequency (treat lambda x: x[1] as an idiom to reference the value of the dictionary entry, not the key—to go from highest to lowest, replace x[1] with −x[1]) [wfc-3.py]
    5. Sorted by frequency first, then alphabetically—note use of function alphafreq(x); you can use any function here, and the parameter is the item [wfc-4.py]
  4. Tuple
    1. Ordered list of elements
    2. Just like a list, but immutable
    3. Simultaneous assignment an example of it

A PDF version is available here.
ECS 10, Basic Concepts of Computing
Fall Quarter 2012