CSci 284 - Homework 0

Due: Tuesday, Jan 27, 2026

This assignment is to be done individually. It is worth 16 points. For full credit:

Written Problems.

For these problems, you'll need to refer to the code examples from Introduction to CSV we used in Exercise 1.

  1. (4 points) The code sample in the Writing to a CSV section calls the open function to create and open the example.csv file. This function takes 4 parameters. Research this function and write out the purpose and meaning of each parameter in this call. So for example what is the purpose of the encoding parameter and the meaning of passing 'utf-8' for it?
  2. (2 points) What would happen if the programmer left off 'Miami, Florida' from the third list (the one that begins with the name 'Ted') so that there were only 2 items in the list? Try it and see.
  3. (2 points) What would happen if the same item was left off the list, but the comma was still there, so that it reads: ['Ted', , 'driver']? Try it and see.
  4. (2 points) What happens if the programmer forgets the last line csvfile.close()?

We'll spend more time reading CSV (and TSV) files than writing them. Refer to the code sample in the Reading from a CSV section to answer these question.
Provide screenshots of both the commands used and the result.

  1. (2 points) In the open call for the writing example, a 'w' is passed so the file is opened for writing. In this example, there is no 'r' passed to the open call. Why is that?
  2. (4 points) As it turns out, the csv module can be used to read/write TSV files as well. Find an example of how to do this, then show how to rewrite just lines 5 and 8 so that if we had a TSV file called presidents.tsv instead, we could read it.