Certified Associate in Python Programming (PCAP) — Question 55
There is a stream named s open for writing. What option will you select to write a line to the stream?
Answer options
- A. s. write (ג€Hello\nג€)
- B. write (s, ג€Helloג€)
- C. s.writeln (ג€Helloג€)
- D. s. writeline (ג€Helloג€)
Correct answer: A
Explanation
The correct answer is A because the method s.write() is specifically designed for writing to the stream, including the newline character. Options B, C, and D do not correctly utilize the stream object s in the context of writing a line as required by the question.