Matching text-file methods to their results

A file object is the object a Python program uses to access an open file. Match each text-file method call to its behaviour. Assume the file is open in a mode that permits the operation, and no operation raises an exception.

Match each term
A.

Accept the supplied string and return its character count, without adding a newline.

B.

Return all remaining lines as a list of strings, preserving their ending newlines when present.

C.

Return the next line as one string, including its ending newline when present.

D.

Return all remaining text as one string, preserving newline characters.

read()

readline()

write(text)

readlines()

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More File Input/Output Questions: