Exam PCAP-31-03 All QuestionsBrowse all questions from this exam
Question 65

What is the expected output of the following code if existing_file is the name of a file located inside the working directory?

    Correct Answer: C

    The code attempts to open a file named 'existing file' in write mode. If the file opens successfully, it will execute the code within the try block, printing '1' and then moving to the else block where it will close the file and print '3'. Since there is no error in opening the file, the except block is not executed. Therefore, the output will be '1 3'.

Discussion
DKAT2023Option: C

C is correct