4.7 Flashcards
what are the two categories of files in Python?
Text files, and Binary files
EOL
End of Line
A_____ is structured as a sequence of lines, where each line includes a sequence of characters.
Text file
Each line in a text file is terminated with a special character called
EOL, or End of Line character.
What is the most common EOL?
A comma, or a newline character.
A ______ character can be used to tell the interpreter that the next character - following it - should be treated as a new line.
a backslash
What is the function of an EOL?
It ends the current line and tells the interpreter a new one has begun.
A _____ is any type of file that is not a text file.
Binary file
T or F: there must be an application that can read and interpret binary files.
True. because of their nature, binary files can only be processed by an application that knows or understands the file’s structure.
Python File Handling (Order the following):
Read or Write a file, close a file, Open a file.
Open a file. Read or write a file. Close a file.
Name all Text File Opening Modes.
r, r+, w, w+, a, a+
Name the file opening mode:
____ opens a file for reading only. The file pointer is placed at the beginning of the file. This is the default mode
r
Name the file opening mode:
_____ opens a file for writing only. Overwrites the file if the file exists. If the file does not exist, creates a new file for reading and writing.
w
Name the file opening mode:
_____ opens a file for both reading and writing. The file pointer is placed at the beginning of the file.
r+
Name the file opening mode:
______ opens a file for both writing and reading. Overwrites the existing file if the file exists. if the file doesn’t exist, creates a new file for reading and writing.
w+