Font size
WorksheetsFile Handling In Python
Total questions: 20
Worksheet time: 9mins
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
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()
Fill in the blank with appropriate statement.
(a)
Write the appropriate statement in the blank.
(a)
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+")
Which function read single line at a time?
read()
read(n)
readline()
readlines()
Which file is not binary file?
student.mp4
student.jpeg
student.csv
student.exe
Where files are store permanently?
RAM
Hard Disk
Cache memory
None of these
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+")
Q.2 Which of the following statements are not true regarding the opening modes of a file?
When you open a file for reading, if the file does not exist, an error occurs.
When you open a file for writing, if the file does not exist, an error occurs
When you open a file for writing, if the file does not exist, a new file is created.
When you open a file for writing, if the file exists, the existing file is overwritten with the new file.
Q.3 Which module is used to work with binary files?
CSV module
pickle module
math module
binary module
Q.5 'try' block is used to
execute a code
through the exceptions
to try some random code
to give errors
Function used to write data in binary format
write()
output()
load()
dump()
What is the use of “a” in file handling?
Read
Write
Append
None of the mentioned
