NEW
Font size
Worksheetspython file handling
Total questions: 10
Worksheet time: 5mins
Select the statement to open a file named MYDATA.dat in read binary mode. Let the file object name be myfile.
myfile=open("MYDATA.dat","rb")
myfile=open("MYDATA.dat","r+")
myfile=open("MYDATA.dat","r")
Mode in the following program to open file for writing in a mode where new data will be added at the end of old data
file =open("poem.txt","__")
r
w
a
r+
Choose the correct statement to close a file stream named myfile:
myfile.terminate()
myfile.end()
myfile.close()
myfile.remove()
What will be the ouput -
f=open('abc.txt','w')
x=f.read()
f.close()
print(x)
Error(not readable)
Error(not writable)
It will read all the data of the file.
none
What will be the output-
f=open('abc.txt','a')
text="xyz"
f.write(text)
f.close()
Writing into the file without erasing old content
Writing into the file by erasing old content
reading from the file without erasing old content
reading from the file by erasing old content
Which function is used to write multiple lines in text file?
write()
writelines()
lines()
print()
Which statement(s) is/are true to open a binary file "Record.dat" for reading and writing ?
file =open("Record.dat","wb")
file =open("Record.dat","rb")
file =open("Record.dat","ab")
file =open("Record.dat","rb+")
The readlines() method returns
a. str
b. a list of lines
c. a list of single characters
d. a list of integers
An absolute path name begins at the
leaf
stem
root
current directory
What will be the output of the following Python code?
True
False
None
error
