Outline for May 20, 2014

Reading: text, §13, 18
Due: Homework #3, due May 21, 2014
  1. Searching a list
    1. Example use: linear search [linsearch.py]
    2. Example use: recursive linear search [rlinsearch.py]
  2. Tower of Hanoi [hanoi.py]
  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()
    2. Reading: readline(), readlines(), read(), read(n)
    3. Writing: write(str), writelines(list)
  5. 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]
  6. 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]

You can also obtain a PDF version of this. Version of May 19, 2014 at 9:36PM