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. What happens when you use the append access mode on a file?


  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. What is the empty string?


  7. What does readline() return when it gets to the end of the file?


  8. What must you do if you want to write an integer to a text file?


  9. What must you do if you read "87" from a text file and want to add it to another number?


  10. Write a for loop that reads and prints a file. Assume you have already created a file object and have stored a reference to it in the variable file.