Join 36000+ teachers and students using TTIO.
Also see the unit on 'Encapsulation'. What is the difference between public and private in OOP?
A public member is accessible from anywhere outside the class but within a program. You can set and get the value of public variables without any member. A private member variable or function cannot be accessed, or even viewed from outside the class. Only the class and friend functions can access private members.
Python doesn't have public OR private attributes. All attributes are accessible to all code. Private attributes are therefore (in Python) merely a convention. “Private” instance variables that cannot be accessed except from inside an object don’t exist in Python. However, there is a convention that is followed by most Python code: a name prefixed with an underscore (e.g. _spam) should be treated as a non-public part of the API (whether it is a function, a method or a data member).
https://www.tutorialsteacher.com/python/public-private-protected-modifiers
https://medium.com/@cesarkohl/public-protected-and-private-properties-in-oop-de03166d23cf
www.teachyourselfpython.com