Certified Associate in Python Programming (PCAP) — Question 91
You are going to read just one character from a stream called s. Which statement would you use?
Answer options
- A. ch = read (s, 1)
- B. ch= s.input (1)
- C. ch= input (s, 1)
- D. ch= s.read (1)
Correct answer: D
Explanation
The correct answer is D because the method s.read(1) is specifically designed to read a specified number of characters from the stream. Options A, B, and C are incorrect as they either use the wrong method or syntax that is not applicable for reading from the stream.