Python Programming - Reading and Writing Files
Exercise : Reading and Writing Files - General Questions
- Reading and Writing Files - General Questions
101.
What does the
file.writelines(lines)
method do?
Answer: Option
Explanation:
file.writelines(lines)
writes multiple lines to the file from a list.
102.
How can you read and print the lines containing the word "error" from a log file named "logfile.txt"?
Answer: Option
Explanation:
Using
line.lower()
to make the comparison case-insensitive.
103.
How can you create a new directory named "data_folder" in the current working directory?
Answer: Option
Explanation:
Using
os.mkdir()
to create a new directory.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers