f.readlines()
f.readline()
f.read()
f.line()
Which of the following error is returned by the given code ?
f = open("test.txt","w")f.write(345)
Syntax Error
Type Error
String Error
Run Time Error
Quick response code
Same format in which the data is held in memory
ASCII format
Unicode format
os.rename(existing_name, new_name)
fq.name = ‘new_name.txt’
os.rename(fp, new_name)
os.set_name(existing_name, new_name)
File size
Current file pointer position
Number of lines
Number of characters remaining
seek()
read()
close()
tell()
readall()
readcharacter()
readchar()
ab
rw
a+
r+
file_object=open(file_name,mode)
open(file_object,file_name,mode)
file_open(file_object,file_name,mode)
file_object=file_open(file_name,mode)
Use multiple write() statements.
Use writelines() method.
Use writeLine() method.
Use append() method.
What will be written to the file?
f = open("test.txt", "w")f.write("ABC")f.write("DEF")f.close()
ABC
DEF
ABCDEF
Error
r
rb
w
reference_point indicates the current position of the file object
reference_point indicates the starting position of the file object
reference_point indicates the ending position of the file object
None of the above
write
output
send
dump
Read two words from file
Read two line from file
Read two character / two bytes
count the number of '2' in file
w+
Data is appended
Error occurs
Old content is erased
Nothing happens
What will be the output of the following code?
f=open("demo.txt","r")print(f.tell())
1
2
-1
0
End of List
End of Line
End of Loop
End of Language
What will be the output of the following code ?
f=open("demo.txt","w+")f.write("Welcome to python")f.seek(5)a=f.read(5)print(a)
Welco
me to
Welcome to Python
e to
End of File
End of Statement
End of program
softspace
mode
closed
rename
readlines()
readline()
readlist()
File Found Error
File Not Exist Error
File Not Found Error
None of these
close_file()
file_close()
end_file()
f.reads()
f.read(all)
f.read( *)
What happens if the file does not exist?
f = open("abc.txt", "r")
New file is created
FileNotFoundError
Returns None
Opens empty file
a
f
t
Curly Braces
Round Brackets
Indentation
Semicolon
read binary
write binary
append binary
read write
What is the output?
f = open("test.txt", "w")f.write("Python")print(f.tell())f.close()
5
6
7
Both of the above
f.seek(-10, 0)
f.seek(10,0)
f.seek(-10, 1)
what is 'f' in the following statement?
f=open("Data.txt","r")
file name
file handle
Mode of file
file handling
end
beginning
anywhere in between the file
write mode
read mode
append mode
Both (A) And (C)
file_exists()
exists_file()
os.path.exists()
check_file()
It is used for object serialization
It is used for object deserialization
All of the mentioned
None of the mentioned
Read mode
Write mode
Append mode
Binary mode
write()
append()
add()
insert()
ar+
_x=2
x=3
_xyz_=5
Write
Read
Append
Read and Write Both
csv.reader(file)
csv.read(file)
csv.readcsv(file)
csv.readcsvdata(file)
try
Brackets
Catch
f = open('data.txt'); f.read()
f = open('data.txt','r'); f.read(n)
myfile = open('data.txt'); f.readline()
f= open('data.txt'); f.readlines()
f.read(5)
f.read()=5
f.readline(5)
f.readlines(5)
Tells you the current position within the file.
Tells the size of file you read
Tells the start position of the file.
Tells the end position of the file.
f = open("data.txt", "a")
f = Open("data.txt", "ab")
f= new("data.txt", "a")
open("data.txt", "a")