Object-Oriented Programming in Python
Dive in and learn how to create classes and leverage inheritance and polymorphism to reuse and optimize code.
Commencer Le Cours Gratuitement4 heures13 vidéos44 exercices84 899 apprenantsDéclaration de réalisation
Créez votre compte gratuit
ou
En continuant, vous acceptez nos Conditions d'utilisation, notre Politique de confidentialité et le fait que vos données sont stockées aux États-Unis.Formation de 2 personnes ou plus ?
Essayer DataCamp for BusinessApprécié par les apprenants de milliers d'entreprises
Description du cours
Object-oriented programming (OOP) is a widely used programming paradigm that reduces development times—making it easier to read, reuse, and maintain your code. OOP shifts the focus from thinking about code as a sequence of actions to looking at your program as a collection of objects that interact with each other. In this course, you’ll learn how to create classes, which act as the blueprints for every object in Python. You’ll then leverage principles called inheritance and polymorphism to reuse and optimize code. Dive in and learn how to create beautiful code that’s clean and efficient!
Formation de 2 personnes ou plus ?
Donnez à votre équipe l’accès à la plateforme DataCamp complète, y compris toutes les fonctionnalités.- 1
OOP Fundamentals
GratuitIn this chapter, you'll learn what object-oriented programming (OOP) is, how it differs from procedural-programming, and how it can be applied. You'll then define your own classes, and learn how to create methods, attributes, and constructors.
What is OOP?50 xpOOP termininology100 xpExploring object interface100 xpClass anatomy: attributes and methods50 xpUnderstanding class definitions100 xpCreate your first class100 xpUsing attributes in class definition100 xpClass anatomy: the __init__ constructor50 xpCorrect use of __init__50 xpAdd a class constructor100 xpWrite a class from scratch100 xp - 2
Inheritance and Polymorphism
Inheritance and polymorphism are the core concepts of OOP that enable efficient and consistent code reuse. Learn how to inherit from a class, customize and redefine methods, and review the differences between class-level data and instance-level data.
Instance and class data50 xpClass-level attributes100 xpChanging class attributes100 xpAlternative constructors100 xpClass inheritance50 xpUnderstanding inheritance100 xpCreate a subclass100 xpCustomizing functionality via inheritance50 xpMethod inheritance100 xpInheritance of class attributes100 xpCustomizing a DataFrame100 xp - 3
Integrating with Standard Python
In this chapter, you'll learn how to make sure that objects that store the same data are considered equal, how to define and customize string representations of objects, and even how to create new error types. Through interactive exercises, you’ll learn how to further customize your classes to make them work more like standard Python data types.
Operator overloading: comparison50 xpOverloading equality100 xpChecking class equality100 xpComparison and inheritance100 xpOperator overloading: string representation50 xpString formatting review100 xpString representation of objects100 xpExceptions50 xpCatching exceptions100 xpCustom exceptions100 xpHandling exception hierarchies100 xp - 4
Best Practices of Class Design
How do you design classes for inheritance? Does Python have private attributes? Is it possible to control attribute access? You'll find answers to these questions (and more) as you learn class design best practices.
Designing for inheritance and polymorphism50 xpPolymorphic methods50 xpSquare and rectangle100 xpManaging data access: private attributes50 xpAttribute naming conventions100 xpUsing internal attributes100 xpProperties50 xpWhat do properties do?50 xpCreate and set properties100 xpRead-only properties100 xpCongratulations!50 xp
Formation de 2 personnes ou plus ?
Donnez à votre équipe l’accès à la plateforme DataCamp complète, y compris toutes les fonctionnalités.collaborateurs
prérequis
Writing Functions in PythonAlex Yarosh
Voir PlusCurriculum Developer @ Cockroach Labs
Qu’est-ce que les autres apprenants ont à dire ?
Inscrivez-vous 15 millions d’apprenants et commencer Object-Oriented Programming in Python Aujourd’hui!
Créez votre compte gratuit
ou
En continuant, vous acceptez nos Conditions d'utilisation, notre Politique de confidentialité et le fait que vos données sont stockées aux États-Unis.