201 Python Programming Exercises Volume 2 by Learning Edcorner

201 Python Programming Exercises Volume 2 by Learning Edcorner
Author: Learning, Edcorner [Learning, Edcorner]
Language: eng
Format: epub
Published: 2021-08-20

f.read()

f.seek(0)

print(f.read())

116. Add the necessary code on line 5 (in between the parentheses of print()) in order to get the current position of the cursor inside test.txt and have the result printed out to the screen.

f = open("test.txt", "r")

f.read(5)

print()

Solution:

f = open("test.txt", "r")

f.read(5)

print(f.tell())

117. Add the necessary code on line 5 (in between the parentheses of print()) in order to get the current mode in which test.txt is open (read, write etc.) and have the result printed out to the screen.

f = open("test.txt", "r")