Certified Associate in Python Programming (PCAP-31-03) — Question 105
Which of the following statements are true? (Choose two.)
Answer options
- A. if invoking open() fails, the value None is returned
- B. open() is a function which returns an int that represents a physical file handle
- C. the second open() argument is optional
- D. instd, outstd, errstd are the names of pre-opened streams
Correct answer: C, D
Explanation
The correct answer is C and D because the second argument in the open() function is indeed optional, allowing for default behavior if not specified. Additionally, instd, outstd, and errstd are predefined streams in Python that facilitate standard input, output, and error handling, respectively. Options A and B are incorrect as they misrepresent the behavior of open() in Python; it does not return None on failure but raises an IOError, and it does not return an int but rather a file object.