r
rb
w
r+
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
read()
readline()
readlines()
load()
write
output
send
dump
softspace
mode
closed
rename
f.seek(-10, 0)
f.seek(10,0)
f.seek(-10, 1)
None of the above
remove((), file_name))
remove (new_file_name, current_file_name,)
remove (file_name)
All of the above
It is used for object serialization
It is used for object deserialization
All of the mentioned
None of the mentioned
write mode
read mode
append mode
Both (A) And (C)
File Found Error
File Not Exist Error
File Not Found Error
None of these
os.rename(existing_name, new_name)
fq.name = ‘new_name.txt’
os.rename(fp, new_name)
os.set_name(existing_name, new_name)
giga bytes
mega bytes
byte
bits
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
Data is appended
Error occurs
Old content is erased
Nothing happens
None of the above.
What will be the output of the following code?
f=open("demo.txt","r")print(f.tell())
1
2
-1
0
Quick response code
Same format in which the data is held in memory
ASCII format
Unicode format
file_exists()
exists_file()
os.path.exists()
check_file()
End Of Folder
Exit Open File
End Of File
Error On File
+
b
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)
Both of the above
Write
Read
Append
Read and Write Both
End of File
End of Line
End of Statement
End of program
f.reads()
f.read()
f.read(all)
f.read( *)
ab
rw
w+
Comma Space Value
Comma Separated Value
Common spaced Value
Compact Structure View
a+
Curly Braces
Round Brackets
Indentation
Semicolon
write()
append()
add()
insert()
close_file()
file_close()
close()
end_file()
File size
Current file pointer position
Number of lines
Number of characters remaining
open_file()
file_open()
open()
read_file()
f = open("data.txt", "a")
f = Open("data.txt", "ab")
f= new("data.txt", "a")
open("data.txt", "a")
rt
Read two words from file
Read two line from file
Read two character / two bytes
count the number of '2' in file
What happens if the file does not exist?
f = open("abc.txt", "r")
New file is created
FileNotFoundError
Returns None
Opens empty file
readall()
readcharacter()
readchar()
raw_input
input
eval
accept
End of List
End of Loop
End of Language
readlist()
It is used for object de-serialization
change the string value to number
extract the list element in simple variable
try
Brackets
Catch
_x=2
x=3
_xyz_=5
end
beginning
anywhere in between the file
5 characters
5 words
5 lines
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.
Dictionary
String
Tuple
List
Use multiple write() statements.
Use writelines() method.
Use writeLine() method.
Use append() method.