Question:

This exception occurs whenever a local or global variable name is not defined.

Show Hint

When debugging in Python, always check if variables or functions are defined in the scope where they are used to avoid \texttt{NameError}.
Updated On: Apr 24, 2025
  • ValueError
  • TypeError
  • OSError
  • NameError
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

A \texttt{NameError} in Python occurs when the code attempts to use a variable or function name that has not been defined yet, either locally or globally. It is raised when Python cannot find the variable or function name in the current namespace. In contrast, \texttt{ValueError}, \texttt{TypeError}, and \texttt{OSError} are associated with other types of errors, such as invalid values, incorrect types, and system-related issues, respectively. Therefore, the correct answer is "NameError."
Was this answer helpful?
0
0

Questions Asked in CUET exam

View More Questions