Python File Handling

Programming Language > Python Programming Language

Improve your understanding of Python file handling with these multiple choice questions. Test your knowledge on reading, writing, and manipulating files in Python, as well as file object attributes and methods. Practice for your next Python programming exam or brush up on your file handling skills with these MCQs. ➲ Python File Handling - Quiz


  • A infile = open(
  • B infile = open(
  • C infile = open(file =
  • D infile = open(file =
  • A When you open a file for reading, if the file does not exist, an error occurs
  • B When you open a file for writing, if the file does not exist, a new file is created
  • C When you open a file for writing, if the file exists, the existing file is overwritten with the new file
  • D All of the mentioned
  • A infile.read(2)
  • B infile.read()
  • C infile.readline()
  • D infile.readlines()
  • A infile.read(2)
  • B infile.read()
  • C infile.readline()
  • D infile.readlines()
  • A split()
  • B spt()
  • C split_line()
  • D All of these
  • A file name
  • B access_mode
  • C dump
  • D pickle
  • A ASCII
  • B Unicode
  • C (A) and (B)
  • D None of these
  • A Opens an existing text file named python.csv to write
  • B Opens an existing text file named python.csv to append
  • C Opens an existing text file named python.csv to read
  • D Opens a new file named python.csv to read
  • A Opens or creates a text file named python.csv to write
  • B Opens or creates a text file named python.csv to append
  • C Opens or creates a text file named python.csv to read
  • D Opens a new file named python.csv to write
  • A Opens or creates a text file named python.csv to write
  • B Opens or creates a text file named python.csv to append
  • C Opens or creates a text file named python.csv to read
  • D Opens a new file named python.csv to append
  • A Opens a text file named python.txt to read from or write to
  • B Opens a text file named python.txt to read
  • C Opens a text file named python.txt to write
  • D Opens a new file named python.txt to append
  • A Opens a text file named python.txt to read
  • B Opens a text file named python.txt to write to or read from
  • C Opens a text file named python.txt to write
  • D Opens a new file named python.txt to append
  • A Opens a text file named python.txt to read
  • B Opens a text file named python.txt to read and write
  • C Opens a text file named python.txt to write to
  • D Opens or creates a text file named python.txt to read from or write to at the end of the file
  • A Opens an existing text file named python.bat to write
  • B Opens an existing binary file named python.bat to write
  • C Opens an existing binary file named python.bat to append
  • D Opens an existing binary file named python.bat to read
  • A Opens or creates a binary file named python.bat to write
  • B Opens or creates a binary file named python.bat to append
  • C Opens or creates a binary file named python.bat to read
  • D Opens a new file named python.bat to write
  • A Opens or creates a binary file named python.bat to write
  • B Opens or creates a binary file named python.bat to append
  • C Opens or creates a binary file named python.bat to read
  • D Opens a new file named python.bat to append
  • A python
  • B python.txt opened
  • C python.txt or FileNotFoundError
  • D python r