Python Programming - Polymorphism - Discussion

Discussion Forum : Polymorphism - General Questions (Q.No. 59)
59.
In Python, what is the purpose of the __len__() method in the context of polymorphism?
To define class attributes
To customize the behavior when an instance is checked for equality using the == operator
To customize the behavior when the len() function is called on an instance
To create a new instance of the class
Answer: Option
Explanation:
The __len__() method is used to customize the behavior when the len() function is called on an instance of the class, allowing for polymorphic behavior.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.