Write
Read
Append
Read and Write Both
raise
goto
try
except
seek()
read()
close()
tell()
move()
shift()
w
rb
rt
r
Data is appended
Error occurs
Old content is erased
Nothing happens
random
sys
math
os
End Of Folder
Exit Open File
End Of File
Error On File
readlines()
readline()
readlist()
readall()
What happens if the file does not exist?
f = open("abc.txt", "r")
New file is created
FileNotFoundError
Returns None
Opens empty file
What will be written to the file?
f = open("test.txt", "w") f.write("ABC") f.write("DEF") f.close()
ABC
DEF
ABCDEF
Error
What is the output?
f = open("test.txt", "w") f.write("Python") print(f.tell()) f.close()
5
6
7
0
File size
Current file pointer position
Number of lines
Number of characters remaining
a
r+
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
What is the output of following?
f = open("test.txt", "r") f.seek(0) print(f.tell())
1
File name
Error is raised
File is appended
File is read-only
File is overwritten
f = open("data.txt", "r") print(f.readline())
One line from the file
Entire file
List of lines
Data is written successfully
File content is overwritten
Raises an exception