Outline for November 10, 2020

Reading: §7, 9
Due: Homework 3, due November 13, 2020


  1. Example: word frequency count
    1. Unsorted, using dget() [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]

  2. Sorting the dictionary
    1. sorted sorts based on keys

  3. Files
    1. What is a file?
    2. What can you do with it? (For example, read, write, append)
    3. Types of files (text, binary)

  4. File Input and Output for text files
    1. Opening and closing: open(filename, mode), close()


UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
MHI 289I, Programming for Health Informatics
Version of November 11, 2020 at 10:43PM

You can also obtain a PDF version of this.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh