11. To open a file c:\scores.txt for appending data, we use . . . . . . . .
12. How can you close a file in Python?
13. What is the purpose of the tell() method in file handling?
14. To open a file c:\scores.txt for writing, we use . . . . . . . .
15. Which of the following statements are true?
16. What is the purpose of the write() method in file handling?
17. To read two characters from a file object infile, we use . . . . . . . .
18. What is the output of the following code:
file = open('data.txt', 'r')
content = file.read()
print(content)
file = open('data.txt', 'r')
content = file.read()
print(content)
19. What is the output of the following code:
with open('data.txt', 'w') as file:
file.write('Hello, world!')
with open('data.txt', 'w') as file:
file.write('Hello, world!')
20. What will be the output of the following code:
with open('data.txt', 'r') as file:
lines = file.readlines()
print(len(lines))
with open('data.txt', 'r') as file:
lines = file.readlines()
print(len(lines))