English

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

Advertisements
Advertisements

Question

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

NameError

Short Note

Solution

It is raised when a local or global variable name is not defined.

 >>> print(name)
       Traceback (most recent call last):
         File "", line 1, in 
           print(name)
       NameError: name 'name' is not defined
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. c) | Page 17
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×