1.2- OOP
Object-Oriented Programming (OOP) in Python
Key Concepts:
- Transition from Procedural to Object-Oriented Programming
* Python supports both procedural and object-oriented programming paradigms
OOP introduces the concept of *classes and objects** as a more structured approach to programming [1][2]
Core OOP Components:
- Classes and Objects
A *class is a blueprint/template** for creating objects
Objects have *attributes and methods** that define their characteristics and behaviors [2][3]
*Self** keyword allows objects to reference and maintain their own data [3]
Advanced OOP Features:
- Inheritance
Classes can *inherit attributes and methods** from other classes
Creates a *hierarchical relationship** between parent (super) and child (sub) classes [4][5]
- Encapsulation
Attributes can be made *private** using double underscore prefix
*Getters and setters** control access to private attributes [6]
- Polymorphism
Enables methods to *behave differently** based on the context
Allows for *flexible and adaptive method implementations** [6][7]