Outline for December 3, 2012
Reading: § 18
Assignment Due: Friday, December 7, 2012 at 11:55 PM
- Review: dictionary
- Collection of key-value pairs
- Dictionary lookup [morse.py]
- Example: word frequency count
- Unsorted [wfc-1.py]
- Sorted alphabetically [wfc-2.py]
- Sorted alphabetically, but dictionary order (note key=str.lower() in sorted [wfc-2a.py]
- 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]
- 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]
- Tuple
- Ordered list of elements
- Just like a list, but immutable
- Simultaneous assignment an example of it
A PDF version is available here.
|
ECS 10, Basic Concepts of Computing
Fall Quarter 2012
|