Python Programming - Reading and Writing Files
Exercise : Reading and Writing Files - General Questions
- Reading and Writing Files - General Questions
96.
What does the
file.is_closed
attribute check for?
Answer: Option
Explanation:
file.is_closed
checks if the file is closed.
97.
How can you read and print the contents of a binary file named "binary.dat"?
Answer: Option
Explanation:
Using
open()
in binary read mode to read and print the binary content.
98.
How can you copy the contents of a text file named "source.txt" to another text file named "destination.txt"?
Answer: Option
Explanation:
Using
with
statement to open both files and copy the content.
99.
What does the
file.tell()
method return?
Answer: Option
Explanation:
file.tell()
returns the current file cursor position.
100.
How can you read and print the first word from each line in a file named "text.txt"?
Answer: Option
Explanation:
Using
line.split()[0]
to get the first word from each line.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers