Python Programming - Classes - Discussion

Discussion Forum : Classes - General Questions (Q.No. 19)
19.
What is the purpose of the __len__ method?
It is called when an object is created.
It defines the length of a string attribute in a class.
It is used to calculate the length of an object, typically for sequences.
It signifies the length of an object's lifecycle.
Answer: Option
Explanation:
The __len__ method is used to define the behavior of the len() function on an object. It is commonly implemented for objects that represent sequences, allowing the determination of their length.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.