ExamVeda
Login
Home
Python Built In Functions
?

What is the purpose of the built-in function dir()?

Answer & Solution
Correct Answer: Option A
The correct answer is Option A: Returns a list of attributes and methods of an object.
The dir() function in Python is used to return a list of attributes and methods of an object.
When called without an argument, it returns the list of names in the current local scope.
For example:
my_list = [1, 2, 3]
print(dir(my_list))  # Output: ['__add__', '__class__', '__contains__', ...]
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.