IT 116: Introduction to Scripting
Class 18 Ungraded Quiz
-
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.
-
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.
-
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.
-
What happens when you use the append access mode on a file?
-
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?
-
What is the empty string?
-
What does readline() return when it gets to the
end of the file?
-
What must you do if you want to write an integer to a text file?
-
What must you do if you read "87" from a text file and want to add it to another number?
-
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.