close_file()
file_close()
close()
end_file()
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
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()
file_exists()
exists_file()
os.path.exists()
check_file()
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)
File size
File name
Number of lines
Current file pointer position
What happens if the file does not exist?
f = open("abc.txt", "r")
New file is created
FileNotFoundError
Returns None
Opens empty file
os.rename(existing_name, new_name)
fq.name = ‘new_name.txt’
os.rename(fp, new_name)
os.set_name(existing_name, new_name)
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.
readlines()
readline()
readlist()
readall()
Number of characters remaining
Comma Space Value
Comma Separated Value
Common spaced Value
Compact Structure View
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
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
What is the output?
f = open("test.txt", "w")f.write("Python")print(f.tell())f.close()
5
6
7
0
ab
rw
r+
w+
remove((), file_name))
remove (new_file_name, current_file_name,)
remove (file_name)
All of the above
seek()
read()
tell()
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
r
rb
w
softspace
mode
closed
rename
Curly Braces
Round Brackets
Indentation
Semicolon
write
output
send
dump
Both of the above
None of the above
end
beginning
anywhere in between the file
Reads one line
Reads all lines into a list
Reads entire file as a string
Reads one character
a
f
t
ar+
End of List
End of Line
End of Loop
End of Language
load()
Read two words from file
Read two line from file
Read two character / two bytes
count the number of '2' in file
File Found Error
File Not Exist Error
File Not Found Error
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
raw_input
input
eval
accept
Dictionary
String
Tuple
List
End of File
End of Statement
End of program
what is 'f' in the following statement?
f=open("Data.txt","r")
file name
file handle
Mode of file
file handling
Data is appended
Error occurs
Old content is erased
Nothing happens
a+
What will be the output of the following code?
f=open("demo.txt","r")print(f.tell())
1
2
-1
Data is written successfully
File content is overwritten
Raises an exception
Read mode
Write mode
Append mode
Binary mode
End Of Folder
Exit Open File
End Of File
Error On File
None of the above.
Write
Read
Append
Read and Write Both
write()
append()
add()
insert()
f = open("test.txt", "r")f.seek(0)print(f.tell())
giga bytes
mega bytes
byte
bits
readcharacter()
readchar()