Friday , September 20 2024

If s is a stream opened in read mode, the following line: q = s.read(1) will read:

Questions BankCategory: Python Essentials 2If s is a stream opened in read mode, the following line: q = s.read(1) will read:
If s is a stream opened in read mode, the following line:

q = s.read(1)

will read:

  • one character from the stream
  • one buffer from the stream
  • one line from the stream
  • one kilobyte from the stream

Explanation: The read() method reads the number of characters/bytes from the file, and returns them as a string. It has the following syntax: filename.read(size), and is able to read the whole file at once, in which case the size argument defaults to -1.

More Questions: Python Essentials 2 (PE2) Course Final Test