IT 116: Introduction to Scripting
Class 18 Ungraded Quiz

  1. Write the Python statement that would create a file object for the file scores.txt for reading and assign it to the variable scores_file.


  2. Write the Python statement that would create a file object for the file scores.txt for writing and assign it to the variable scores_file.


  3. Write the Python statement that would create a file object for the file scores.txt for appending and assign it to the variable scores_file.


  4. If you had the file variable scores_file and you wanted to get all the data in the file and store it in the variable results what Python statement would you write?


  5. 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?


  6. If you wanted to write "78" to a file for which you had the file variable scores_file what Python statement would you write?


  7. What does the method used to return a single line of a file return when it it reaches the end of the file?


  8. What must you do if you have read the entire contents of a file and now want to read it again?


  9. What does the append access mode do to a file?


  10. Write a for loop which reads in integers stored in a file to which you have read access through the scores_file and adds them to the accumulator variable total.