16
QuizMultiple Choice

Test: Programming Algorithms

Question 16 • Intro to Computer Science B

This line of code is in your program. outFile = open("another.txt", "a") How will outFile interact with the file it opens?

Answer
A
read and write to the file
B
write to the file, creating a new file
C
write to the file, adding to the current contents of the file
D
read from the file

Explanation

The mode "a" means append. It lets the program write to the file, adding new content after anything already there rather than replacing the existing contents. If the file does not exist, append mode creates it. Therefore, the correct choice is “write to the file, adding to the current contents of the file.”

AI-written and checked against the verified answer.

Previous
Next