File Handling Quiz-11

Share with others

Welcome to your File Handling Quiz-11

Name
Email
School Name
Q101. Select the correct statement about the code given below:
>>> myobj=open("myfile.txt", 'r')
>>> print(myobj.readlines())
Q102. Write the output of the following:
f=open("test.txt","w+")
L = ["My name\n", "is\n", "Amit"]
f.writelines(L)
f.seek(0)
a=f.readlines()
print(type(a))
Q103. Which of the following function return the data of the file in the form of list?
Q104. Ravi has written a program which is showing an error. As a friend of Ravi, help him to identify the wrong statement.
f=open("test.txt","w") #Statement1
L = ["My name\n", "is\n", "Amit"] #Statement2
f.writeline(L) #Statement3
f.close() #Statement4
Q105. ___________ function returns an integer that specifies the current position of the file object in the file.
Q106. ______________ method is used to position the file object at a particular position in a file.
Q107. In reference to the code given below, the file object will move ____________ bytes.
file_object.seek(10, 0)
Q108. Ravi wants to move the file object 5 bytes from the current position of the file object. As a friend of Ravi, help him to write the code.
Q109. Write the output of the following code:
f=open("test.txt","w+")
f.write("My name is Amit\n")
f.seek(5,0)
a=f.read(5)

print(a)
Q110. Write the output of the following:
f=open("test.txt","w+")
f.write("MynameisAmit\n")
print(f.tell())


Share with others

Leave a Reply