object-oriented programming (OOP) | Python Glossary – Real Python
A programming paradigm that organizes code into objects that contain both data and code.
En bref
Ajouté le
18 mars 2026
Matière et domaine
coding · object-oriented-programming-oop
Niveaux scolaires
8e année–12e année (Terminale)
Type de page
Article
Introduction
Object-Oriented Programming (OOP) Overview
- Definition: A programming paradigm that organizes code into "objects," which bundle data (properties) and behavior (methods) to mirror real-world entities.
- Core Components:
- Objects: Self-contained components representing specific entities.
- Classes: Blueprints used to create objects.
- Properties: Data attributes that store details about an object.
- Methods: Functions that define the behaviors an object can perform.
- Key Principles:
- Encapsulation: Hiding internal implementation details and exposing only necessary interfaces.
- Inheritance: Allowing new classes to derive features from existing ones.
- Polymorphism: Enabling different objects to utilize the same interface.
- Modularity: Organizing code into independent, manageable, and logical sections.
- Benefits: Improves code reuse, scalability, and maintainability.
- Implementation: In Python, classes are defined using the
classkeyword, and instances are created by calling the class with specific arguments (e.g.,toyota = Car("red", "Toyota", 2010)).
Avis de la communauté
Pas encore d’avis publiés. Soyez le premier à partager votre expérience.