Python Programming - Reading and Writing Files
Exercise : Reading and Writing Files - General Questions
- Reading and Writing Files - General Questions
81.
What is the purpose of the
file.flush()
method?
Answer: Option
Explanation:
file.flush()
flushes the internal buffer to the file.
82.
How can you append the text "Additional content" to an existing file named "existing.txt"?
Answer: Option
Explanation:
Using
open()
in append mode to add content to an existing file.
83.
What does the
file.readline()
method do?
Answer: Option
Explanation:
file.readline()
reads the next line from the file.
84.
How can you check if a file named "data.txt" exists in the current directory?
Answer: Option
Explanation:
Using
os.path.isfile()
to check if the path refers to a regular file.
85.
What is the purpose of the
file.truncate()
method?
Answer: Option
Explanation:
file.truncate()
truncates the file at the current position.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers