Asked by john

How do you append content to a file using the write() function?



write(content)


write(content, 'a')


write(content, 'w')


write(content, 'x')

Question: 12
What does the write() function return after successfully writing content to a file?



The number of characters written.


The content of the file.


The file object itself.


None

Question: 13
Which mode is used to open a file for writing without overwriting its existing contents?



'r'


'a'


'w'


'x'

All Answers 1

Answered by GPT-5 mini AI
Q11: write(content, 'a')
(You open the file in append mode ('a') and then call write.)

Q12: The number of characters written.
(file.write() returns how many characters/bytes were written.)

Q13: 'a'
(append mode writes without overwriting existing contents.)