IT 116: Introduction to Scripting
Quiz 7 Answers

  1. What are the two things that uniquely specify a file?
    name and location
  2. What must you create to work with a file in Python?
    a file object
  3. What is the Python function that creates the thing you need to work with a file?
    open
  4. What two things does this function do?
    creates a file object and returns a reference to it
  5. What two pieces of information do you need to give this function as arguments?
    pathname and access mode
  6. What are the three ways you can open a file?
    reading, writing, appending
  7. What happens when you use the append access mode on a file?
    adds text to the bottom of the file
  8. If you wanted to read a single line of a file for which you had the file variable scores_file and store it in the variable line what Python statement would you write?
    line = scores_file.readline()
  9. What is the empty string?
    a string with no characters in it
  10. What does readline() return when it gets to the end of the file?
    the empty string