Python Programming - Classes - Discussion

Discussion Forum : Classes - General Questions (Q.No. 4)
4.
What is the purpose of the __str__ method?
It converts an object to a string representation.
It is used to define a string variable in a class.
It represents the string type in Python.
It is required for string concatenation.
Answer: Option
Explanation:
The __str__ method is called when the str() function is used on an object. It is used to provide a human-readable string representation of the object.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.