PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 37


You are going to read just one character from a stream called s. Which statement would you use?

Show Answer
Correct Answer: D

To read just one character from a stream called 's', the correct statement to use is 'ch = s.read(1)'. The method 's.read(1)' instructs the stream to read exactly one character from it, which is the expected behavior. This method call is standard in many programming languages including Python, where 's' is a file or any input stream object.

Discussion

3 comments
Sign in to comment
ArulkumarOption: D
Apr 15, 2023

reader = open("odd_even.txt") ch=reader.read(1) print(ch) Ans : D

macxszOption: D
May 3, 2022

answer" D. ch=s.read(1)

666_mOption: D
May 6, 2022

D. ch= s.read (1)---> correct