Question 8
Consider the following snippet of code:
filename = "test.txt"
with open(filename, "w") as f:
f.write("\n".join((f"Line**{i}**" for i in range(1,11))))
with open(filename, "r") as f:
f.readline()
f.readline()
print(f.read(5))
f.readline()
print(f.read(10))
f.seek(0)
print(f.read(5))
f.readline()
f.readline()
print(f.read(5))
Select all that apply.
Note
•
If a value is passed to f.read , it reads that many number of characters from the current position of the file pointer.
•
The f.seek method moves the position of the file pointer to the given number of chars after the start of the file.
The first line of the output is Line3 .
The second line of the output is Line5 .
The second line of the output is Line4 .
There are 5 lines in the output.
The output contains empty lines.