Practice mode Python

Which mode should be passed to open() to add text to the end of an existing file without erasing it?

Correct answer C. 'a'

Explanation

Mode 'a' opens a file for appending, so all writes go to the end and existing content is kept; the file is created if it does not exist. 'w' truncates the file first, 'r' is read-only, and 'x' is for exclusive creation and fails if the file already exists.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.