IT 117: Intermediate to Scripting
Answers to Class 20 Ungraded Quiz

  1. What does Python call the process by which an object can be stored as a file on disk?
    pickling
  2. If you want to turn an object into a file on disk, what statement must you have at the top of the script file?
    import pickle
  3. What access mode would you use to open a pickled file for reading?
    rb
  4. Write a Python statement that opens the pickle file students.pk for reading and assigns the result to the variable pickle_file.
    pickle_file = open('students.pk', 'rb')
  5. Write the name of the method you would use to read data from a pickle file.
    pickle.load
  6. What access mode would you use to open a pickled file for writing?
    wb
  7. Write a Python statement that opens the pickle file students.pk for writing and assigns the result to the variable pickle_file.
    pickle_file = open('students.pk', 'wb')
  8. Write the name of the method you would use to write data to a pickle file.
    pickle.dump
  9. If you have an import statement in a file defining the class, where must that statement appear?
    before the class declaration
  10. If you have a statement defining a global variable in a file defining the class, where must that statement appear?
    before the class declaration