Certified Associate in Python Programming (PCAP-31-03) — Question 23
Which of the following statements are true? (Choose two.)
Answer options
- A. if invoking open() fails, an exception is raised
- B. instd, outstd, errstd are the names of pre-opened streams
- C. open() requires a second argument
- D. open() is a function which returns an object that represents a physical file
Correct answer: A, C
Explanation
Option A is correct because if the open() function cannot successfully open a file, it will raise an exception indicating the failure. Option C is also correct as open() typically requires a second argument for the mode in which the file is opened. Options B and D are incorrect; B is misleading as the correct names are stdin, stdout, and stderr, and D is not precise since open() returns a file object, not an object representing a physical file.