Font size
WorksheetsData file Handling in Python
Total questions: 36
Worksheet time: 17mins
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()
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
Which file execute faster?
Text file
Binary file
CSV file
Mode used for reading and writing in binary file
wb
w
wb+
w+
Function used to write data in binary format
write()
output()
load()
dump()
The type of operation possible in an opened file is governed by
File Object
File Mode
File Path
open() Method
Module used to read and write into binary files
dump
load
pickle
open
Function returns the current position of file pointer in the file
tell()
seek()
read()
flush()
Which of the following is not a valid attribute of a file object (fp)?
fp.name
fp.closed
fp.size
fp.mode
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
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+")
An absolute path name begins at the
leaf
stem
root
current directory
Which file is not binary file?
student.mp4
student.jpeg
student.csv
student.exe
Which is not a text file?
data.txt
data.csv
data.rft
data.mp3
Which function read single line at a time?
read()
read(n)
readline()
readlines()
Which memory is volatile memory?
RAM
Hard Disk
CD
Pen drive
Where files are store permanently?
RAM
Hard Disk
Cache memory
None of these
Which are the text editor software?
Notepad
Wordpad
MS word
PPT
In our computer all software and files are store in
DVD
CD
RAM
Hard Disk
By default python program save in which drive?
D Drive
C Drive
E Drive
F Drive
How do Python represent a Complex number with real part (3) and imaginary part ( -2.5)
3+2.5i
3-2.5i
3+2.5j
3-2.5j
Do you think the CS Online class is interesting?
yes
no
may be
no comments
