Python Programming - Encapsulation - Discussion

Discussion Forum : Encapsulation - General Questions (Q.No. 42)
42.
In Python, what is the purpose of the __str__() method in a class?
To create a new instance of a class
To define a private variable
To provide a string representation of the object
To access a global variable
Answer: Option
Explanation:
The __str__() method in Python is used to provide a string representation of the object when the str() function is called.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.