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

What is the expected output of the following code if there is no file named non_existing_file inside the working directory?

    Correct Answer: B

    The code attempts to open a non-existent file, which raises an IOError. The code in the 'except' block catches this error and prints the error number followed by '2'. Since the file opening failed, the 'else' block is not executed, so the output is '2 2'.

Discussion
DKAT2023Option: B

B is correct