PCAP-31-03 Exam QuestionsBrowse all questions from this exam

PCAP-31-03 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?

Show Answer
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

1 comment
Sign in to comment
DKAT2023Option: B
Jul 1, 2024

B is correct