File Handling (MCQ'S)
File Handling (MCQ'S)
*******************************************************************************************
*******
29. To read two characters from a file object infile, we use ____________
a) infile.read(2)
b) infile.read()
c) infile.readline()
d) infile.readlines()
30. To read the entire remaining contents of the file as a string from a file object infile, we
use ____________
a) infile.read(2)
b) infile.read()
c) infile.readline()
d) infile.readlines()
1. f = None
2. for i in range (5):
3. with open("data.txt", "w") as f:
4. if i > 2:
5. break
6. print(f.closed)
a) True
b) False
c) None
d) Error
32. To read the next line of the file from a file object infile, we use ____________
a) infile.read(2)
b) infile.read()
c) infile.readline()
d) infile.readlines()
33. To read the remaining lines of the file from a file object infile, we use ____________
a) infile.read(2)
b) infile.read()
c) infile.readline()
d) infile.readlines()
a) Compilation Error
b) Syntax Error
c) Displays Output
d) None of the mentioned
a) Compilation Error
b) Runtime Error
c) No Output
d) Flushes the file when closing them
26. Which of the following are the modes of both writing and reading in binary format in
file?
a) wb+
b) w
c) wb
d) w+
28. How do you get the current position within the file?
a) fp.seek()
b) fp.tell()
c) fp.loc
d) fp.pos
f = open('kvs.txt', 'w')
f.write('This is my Record File')
# reading the entire content of file from current position
rea = f.______ #Line 5
print(rea)
f.close()