What will be written to the file?
f = open("test.txt", "w")f.write("ABC")f.write("DEF")f.close()
ABC
DEF
ABCDEF
Error
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()
End of File
End of Line
End of Statement
End of program
Quick response code
Same format in which the data is held in memory
ASCII format
Unicode format
Read mode
Write mode
Append mode
Binary mode
seek()
read()
close()
tell()
What happens if the file does not exist?
f = open("abc.txt", "r")
New file is created
FileNotFoundError
Returns None
Opens empty file
try
Brackets
Indentation
Catch
End Of Folder
Exit Open File
End Of File
Error On File
softspace
mode
closed
rename
Comma Space Value
Comma Separated Value
Common spaced Value
Compact Structure View
File size
Current file pointer position
Number of lines
Number of characters remaining
write()
append()
add()
insert()
r
w
a
r+
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
read binary
write binary
append binary
read write
_x=2
x=3
_xyz_=5
None of these
rb
f.reads()
f.read()
f.read(all)
f.read( *)
readlines()
Both of the above
None of the above
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
what is 'f' in the following statement?
f=open("Data.txt","r")
file name
file handle
Mode of file
file handling
Dictionary
String
Tuple
List
Curly Braces
Round Brackets
Semicolon
readall()
readcharacter()
readchar()
None of the above.
It is used for object serialization
It is used for object deserialization
All of the mentioned
None of the mentioned
file_exists()
exists_file()
os.path.exists()
check_file()
f.seek(-10, 0)
f.seek(10,0)
f.seek(-10, 1)
File Found Error
File Not Exist Error
File Not Found Error
f = open("data.txt", "a")
f = Open("data.txt", "ab")
f= new("data.txt", "a")
open("data.txt", "a")
open_file()
file_open()
open()
read_file()
readline()
readlist()
close_file()
file_close()
end_file()
What will be the output?
f = open("test.txt", "w")f.write("Python")f.seek(0)print(f.read())
Python
Empty String
UnsupportedOperation Error
None
f.readlines()
f.readline()
f.line()
write
output
send
dump
ab
rw
w+
remove((), file_name))
remove (new_file_name, current_file_name,)
remove (file_name)
All of the above
raw_input
input
eval
accept
rt
ar+
Read two words from file
Read two line from file
Read two character / two bytes
count the number of '2' in file
What is the output?
f = open("test.txt", "w")f.write("Python")print(f.tell())f.close()
5
6
7
0
raise
goto
except
a+
os.rename(existing_name, new_name)
fq.name = ‘new_name.txt’
os.rename(fp, new_name)
os.set_name(existing_name, new_name)
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)
Write
Read
Append
Read and Write Both