Skip to main contentSkip to solution

______ is raised when the file specified in a program statement cannot be opened.

Solution

✅ Correct Option: 2

IOError is raised when an input/output operation fails, including when the file named in an open() statement cannot be opened (for example, the file does not exist or permission is denied).

In Python 3, IOError is an alias of OSError, and the more specific FileNotFoundError is a subclass of it.


EOFError: raised when input() reaches the end of input without reading any data, not when a file fails to open.

ImportError: raised when an import statement cannot find or load a module.

ValueError: raised when a function gets an argument of the right type but an unsuitable value, such as int("abc").

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question