Python Programming - Polymorphism - Discussion

Discussion Forum : Polymorphism - General Questions (Q.No. 39)
39.
In Python, what is the purpose of the __str__() method?
To define class attributes
To create a new instance of the class
To represent the object as a string for display purposes
To customize the behavior when an item is accessed using square brackets on an instance
Answer: Option
Explanation:
The __str__() method is used to represent the object as a string for display purposes, providing a human-readable representation.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.