Certified Associate in Python Programming (PCAP) — Question 75
Which of the following statements are true? (Choose two.)
Answer options
- A. if invoking open () fails, an exception is raised
- B. open () requires a second argument
- C. open () is a function which returns an object that represents a physical file
- D. instd, outstd. errstd are the names of pre-opened streams
Correct answer: A, C
Explanation
Option A is correct because if the open() function fails, it raises an exception to indicate the error. Option C is also correct as open() indeed returns a file object that allows interaction with a physical file. Options B and D are incorrect; open() does not always require a second argument, and the correct names for the standard streams are sys.stdin, sys.stdout, and sys.stderr.