f = open("data.txt", "a")
f = Open("data.txt", "ab")
f= new("data.txt", "a")
open("data.txt", "a")
ab
rw
a+
r+
write mode
read mode
append mode
Both (A) And (C)
End of File
End of Line
End of Statement
End of program
Curly Braces
Round Brackets
Indentation
Semicolon
write()
append()
add()
insert()
What is the output?
f = open("test.txt", "w")f.write("Python")print(f.tell())f.close()
5
6
7
0
Quick response code
Same format in which the data is held in memory
ASCII format
Unicode format
w
rb
rt
r
What is the output of following?
f = open("data.txt", "r")print(f.readline())
One line from the file
Entire file
List of lines
Error
Dictionary
String
Tuple
List
What happens if the file does not exist?
f = open("abc.txt", "r")
New file is created
FileNotFoundError
Returns None
Opens empty file
raw_input
input
eval
accept
random
sys
math
os
closed
softspace
rename
None of the above.
sets the file's current position at the offset
sets the file's previous position at the offset
sets the file's current position within the file
None of these
f.read(5)
f.read()=5
f.readline(5)
f.readlines(5)
What will be written to the file?
f = open("test.txt", "w")f.write("ABC")f.write("DEF")f.close()
ABC
DEF
ABCDEF
w+
a
x
Reads one line
Reads all lines into a list
Reads entire file as a string
Reads one character
Data is written successfully
File content is overwritten
Raises an exception
Nothing happens
end
beginning
anywhere in between the file
None of the above
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)
try
Brackets
Catch
File size
Current file pointer position
Number of lines
Number of characters remaining
os.rename(existing_name, new_name)
fq.name = ‘new_name.txt’
os.rename(fp, new_name)
os.set_name(existing_name, new_name)
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
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()
mode
readlines()
readline()
readlist()
readall()
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
End of List
End of Loop
End of Language
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
_x=2
x=3
_xyz_=5
file()
open()
fopen()
load()
file_exists()
exists_file()
os.path.exists()
check_file()
read()
readcharacter()
readchar()
seek()
close()
tell()
f.readlines()
f.readline()
f.read()
f.line()
ar+
Write
Read
Append
Read and Write Both
close_file()
file_close()
end_file()
File Found Error
File Not Exist Error
File Not Found Error
Error is raised
File is appended
File is read-only
File is overwritten
raise
goto
except
Read mode
Write mode
Append mode
Binary mode
writelines()
remove((), file_name))
remove (new_file_name, current_file_name,)
remove (file_name)
All of the above