✏️ Explanatory Question

What is the difference between public, protected, and private attributes in Python?

👁 301 Views
📘 Detailed Answer
💡

Answer with Explanation

Answer: Public attributes can be accessed and modified from anywhere in the program. Protected attributes can only be accessed and modified by the class and its subclasses. Private attributes can only be accessed and modified by the class, and not its subclasses or other modules.