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