Outline for February 13

Reading: text, §7
Due: Homework 3, due on February 15 at 11:55pm

  1. Characters and representations
    1. How characters are represented internally [chr.py, ord.py]
    2. Figuring out the position of a character in the alphabet
  2. Files
    1. What is a file?
    2. What can you do with it? (For example, read, write, append)
    3. Types of files (text, binary)
  3. File Input and output for text files
    1. Opening and closing: open(filename, mode), close()
    2. Reading: readline(), readlines(), read(), read(n)
    3. Writing: write(str), writelines(list)
  4. Examples
    1. Print out a named file [fileio1.py]
    2. Print out a named file and prepend line numbers [fileio2.py]
    3. Store the output in filename.lst [fileio3.py]
    4. Same, but use print rather than write [fileio4.py]
  5. Examples
    1. Put lines in a file in random order [randlines.py]
    2. Read in a list of words from a file, then search it as requested; similar to linear search program [search-1.py]
    3. Now see how many words you checked total [search-1c.py]

UC Davis seal
Matt Bishop
Office: 2209 Watershed Science
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
You can also obtain a PDF version of this.
Version of February 11, 2019 at 8:10PM