English

When are the following built-in exceptions raised? Give examples to support your answer. IOError - Computer Science (Python)

Advertisements
Advertisements

Question

When are the following built-in exceptions raised? Give examples to support your answer.

IOError

Short Note

Solution

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

 >>> f = open("abc.txt",'r')
       Traceback (most recent call last):
         File "", line 1, in 
           f = open("abc.txt",'r')
       FileNotFoundError: [Errno 2] No such file or directory: 'abc.txt'
shaalaa.com
Built-in Exceptions
  Is there an error in this question or solution?
Chapter 1: Exception Handling in Python - Exercise [Page 17]

APPEARS IN

NCERT Computer Science [English] Class 12
Chapter 1 Exception Handling in Python
Exercise | Q 2. b) | Page 17
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×