Python Programming - Encapsulation - Discussion
Discussion Forum : Encapsulation - General Questions (Q.No. 60)
60.
In Python, what is the purpose of using a double underscore prefix before a variable, such as __price?
class Product:
def __init__(self, name, __price):
self.name = name
self.__price = __price
Answer: Option
Explanation:
The double underscore prefix (__price) indicates that it is a private variable, demonstrating encapsulation by hiding the implementation details.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers