What is the purpose of the truncate() method in file handling?
Select an option to see the answer and solution.
To read the remaining lines of the file from a file object infile, we use . . . . . . . .
Select an option to see the answer and solution.
What is the purpose of the a mode when opening a file in Python?
Select an option to see the answer and solution.
Which function is used to close a file in python?
Select an option to see the answer and solution.
How do you get the current position within the file?
Select an option to see the answer and solution.
What will be the output of the following Python code?
import sys
sys.stdout.write(' Hello\n')
sys.stdout.write('Python\n')
Select an option to see the answer and solution.
How do you delete a file?
Select an option to see the answer and solution.
How can you remove a file in Python?
Select an option to see the answer and solution.
Which of the following is not a valid attribute of a file object (fp)?
Select an option to see the answer and solution.
What is the use of truncate() method in file?
Select an option to see the answer and solution.
How do you change the file position to an offset value from the start?
Select an option to see the answer and solution.
How can you open a file for both reading and writing in Python?
Select an option to see the answer and solution.
What is the difference between r+ and w+ modes?
Select an option to see the answer and solution.
What is the purpose of the b mode when opening a file in Python?
Select an option to see the answer and solution.
What is the output of the following code:
with open('data.txt', 'r') as file:
lines = file.read().splitlines()
print(len(lines))
Select an option to see the answer and solution.
What is the current syntax of rename() a file?
Select an option to see the answer and solution.
What will be the output of the following Python code?
fo = open("foo.txt", "wb")
print "Name of the file: ", fo.name
fo.flush()
fo.close()
Select an option to see the answer and solution.
What is the correct syntax of open() function?
Select an option to see the answer and solution.
What is the purpose of the readlines() method in file handling?
Select an option to see the answer and solution.
Is it possible to create a text file in python?
Select an option to see the answer and solution.