You are going to read just one character from a stream called s. Which statement would you use?
You are going to read just one character from a stream called s. Which statement would you use?
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.
reader = open("odd_even.txt") ch=reader.read(1) print(ch) Ans : D
D. ch= s.read (1)---> correct
answer" D. ch=s.read(1)