Certified Associate in Python Programming (PCAP-31-03) — Question 110

Which of the following statements are true? (Choose two.)

Answer options

Correct answer: A, C

Explanation

Statement A is correct because when opening a file in read mode ('r'), the file must exist; otherwise, an error occurs. Statement C is also true because using 'w' mode will truncate the file and erase its previous contents if the file already exists. The other statements are incorrect as the default mode for open() is 'r', not 'w', and there is no closefile() function; the correct function to close a file is close().