{"id":47857,"date":"2021-10-25T06:09:47","date_gmt":"2021-10-25T00:39:47","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/"},"modified":"2025-06-12T03:42:35","modified_gmt":"2025-06-11T22:12:35","slug":"oops-concepts-in-python","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/","title":{"rendered":"OOPs Concepts in Python"},"content":{"rendered":"\n<p><strong>Object-Oriented Programming (OOP)<\/strong> is a way of organizing your code. It lets you create programs that are easy to understand and manage. In Python, OOP uses \"objects\" to represent real-world things or ideas. These objects combine data and the actions that can be performed on that data.<\/p>\n\n\n\n<p>Using OOP helps you write code that is reusable and flexible. You can build complex systems by breaking them into smaller, manageable parts. This makes your programs easier to update and fix over time.<\/p>\n\n\n\n<p>Here are the main concepts in Python OOP:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Classes<\/strong><\/li>\n\n\n\n<li><strong>Objects<\/strong><\/li>\n\n\n\n<li><strong>Inheritance<\/strong><\/li>\n\n\n\n<li><strong>Encapsulation<\/strong><\/li>\n\n\n\n<li><strong>Polymorphism<\/strong><\/li>\n\n\n\n<li><strong>Abstraction<\/strong><\/li>\n<\/ul>\n\n\n\n<p>You can use these concepts to write better Python code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1-classes\">1. Classes<\/h2>\n\n\n\n<p>A <strong>class<\/strong> is like a blueprint or a template. It defines a set of rules for creating objects. Think of a class as the design for a house. The design tells you what the house will have: how many rooms, where the windows are, and so on.<\/p>\n\n\n\n<p>A class in Python defines:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Attributes:<\/strong> These are the data or properties that objects of this class will have. For a <code>Car<\/code> class, attributes might be <code>color<\/code>, <code>make<\/code>, or <code>model<\/code>.<\/li>\n\n\n\n<li><strong>Methods:<\/strong> These are the functions or actions that objects of this class can perform. For a <code>Car<\/code> class, methods might be <code>start_engine()<\/code>, <code>drive()<\/code>, or <code>stop()<\/code>.<\/li>\n<\/ul>\n\n\n\n<p>You create a class using the <code>class<\/code> keyword.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nclass Car:\n    # This is an attribute common to all cars\n    wheels = 4\n\n    # This is a special method called a constructor.\n    # It runs when you create a new Car object.\n    def __init__(self, make, model, color):\n        self.make = make      # Instance attribute\n        self.model = model    # Instance attribute\n        self.color = color    # Instance attribute\n\n    # This is a method (an action the car can do)\n    def drive(self):\n        print(f&quot;The {self.color} {self.make} {self.model} is driving.&quot;)\n<\/pre><\/div>\n\n\n<p>In this <code>Car<\/code> class, <code>wheels<\/code> is a class attribute. <code>make<\/code>, <code>model<\/code>, and <code>color<\/code> are instance attributes. The <code>drive()<\/code> method lets a car object perform an action.<\/p>\n\n\n\n    <div class=\"courses-cta-container\">\n        <div class=\"courses-cta-card\">\n            <div class=\"courses-cta-header\">\n                <div class=\"courses-learn-icon\"><\/div>\n                <span class=\"courses-learn-text\">Academy Pro<\/span>\n            <\/div>\n            <p class=\"courses-cta-title\">\n                <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/master-python-programming\" class=\"courses-cta-title-link\">Python Programming Course<\/a>\n            <\/p>\n            <p class=\"courses-cta-description\">In this course, you will learn the fundamentals of Python: from basic syntax to mastering data structures, loops, and functions. You will also explore OOP concepts and objects to build robust programs.<\/p>\n            <div class=\"courses-cta-stats\">\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-user-icon\"><\/div>\n                    <span>11.5 Hrs<\/span>\n                <\/div>\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-star-icon\"><\/div>\n                    <span>51 Coding Exercises<\/span>\n                <\/div>\n            <\/div>\n            <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/master-python-programming\" class=\"courses-cta-button\">\n                Start Free Trial\n                <div class=\"courses-arrow-icon\"><\/div>\n            <\/a>\n        <\/div>\n    <\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2-objects\">2. Objects<\/h2>\n\n\n\n<p>An <strong>object<\/strong> is a real instance of a class. If a class is a blueprint for a house, an object is an actual house built from that blueprint. You can build many houses from one design, and each house is an object.<\/p>\n\n\n\n<p>Each object has its own unique set of data based on the class's attributes.<\/p>\n\n\n\n<p>You create an object by calling the class name like a function.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# Create an object (an instance) of the Car class\nmy_car = Car(&quot;Toyota&quot;, &quot;Camry&quot;, &quot;blue&quot;)\nyour_car = Car(&quot;Honda&quot;, &quot;Civic&quot;, &quot;red&quot;)\n\n# Access attributes of the objects\nprint(f&quot;My car is a {my_car.color} {my_car.make} {my_car.model}.&quot;)\nprint(f&quot;Your car has {your_car.wheels} wheels.&quot;)\n\n# Call methods on the objects\nmy_car.drive()\nyour_car.drive()\n<\/pre><\/div>\n\n\n<p>This code outputs:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nMy car is a blue Toyota Camry.\nYour car has 4 wheels.\nThe blue Toyota Camry is driving.\nThe red Honda Civic is driving.\n<\/pre><\/div>\n\n\n<p><code>my_car<\/code> and <code>your_car<\/code> are two different objects. They use the same <code>Car<\/code> blueprint but have their own specific color, make, and model.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3-inheritance\">3. Inheritance<\/h2>\n\n\n\n<p><strong>Inheritance<\/strong> lets you create a new class from an existing class. The new class, called the \"child class\" or \"derived class,\" gets all the attributes and methods of the original class, called the \"parent class\" or \"base class.\"<\/p>\n\n\n\n<p>This helps you reuse code. You do not have to write the same code again. You can also add new features or change existing ones in the child class.<\/p>\n\n\n\n<p>Think of a <code>Vehicle<\/code> class as a parent. A <code>Car<\/code> class and a <code>Motorcycle<\/code> class can inherit from <code>Vehicle<\/code>. Both cars and motorcycles are vehicles.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nclass Vehicle:\n    def __init__(self, brand):\n        self.brand = brand\n\n    def start_engine(self):\n        print(f&quot;{self.brand} engine started.&quot;)\n\nclass Car(Vehicle):\n    def __init__(self, brand, model):\n        super().__init__(brand) # Call parent&#039;s constructor\n        self.model = model\n\n    def drive(self):\n        print(f&quot;The {self.brand} {self.model} is driving on four wheels.&quot;)\n\nclass Motorcycle(Vehicle):\n    def __init__(self, brand, type_moto):\n        super().__init__(brand)\n        self.type_moto = type_moto\n\n    def ride(self):\n        print(f&quot;The {self.brand} {self.type_moto} is riding on two wheels.&quot;)\n\n# Create objects of child classes\nmy_car = Car(&quot;Ford&quot;, &quot;Focus&quot;)\nmy_bike = Motorcycle(&quot;Harley-Davidson&quot;, &quot;Cruiser&quot;)\n\n# Child classes use methods from parent\nmy_car.start_engine()\nmy_bike.start_engine()\n\n# Child classes use their own methods\nmy_car.drive()\nmy_bike.ride()\n<\/pre><\/div>\n\n\n<p>This code outputs:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nFord engine started.\nHarley-Davidson engine started.\nThe Ford Focus is driving on four wheels.\nThe Harley-Davidson Cruiser is riding on two wheels.\n<\/pre><\/div>\n\n\n<p>The <code>Car<\/code> and <code>Motorcycle<\/code> classes inherit <code>start_engine()<\/code> from <code>Vehicle<\/code>. They also have their own specific methods (<code>drive()<\/code> and <code>ride()<\/code>).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4-encapsulation\">4. Encapsulation<\/h2>\n\n\n\n<p><strong>Encapsulation<\/strong> means bundling data (attributes) and methods that work on that data into a single unit (a class). It also means hiding the internal details of how a class works. You expose only what is necessary to the outside world.<\/p>\n\n\n\n<p>Think of a remote control for a TV. You use buttons to change channels or volume. You do not need to know how the remote's circuits work inside. Encapsulation works like this.<\/p>\n\n\n\n<p>In Python, you can indicate that an attribute or method is \"private\" or \"protected\" by using underscores:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Public:<\/strong> Attributes\/methods without underscores or with a single underscore. You can access them from anywhere.<\/li>\n\n\n\n<li><strong>Protected:<\/strong> Attributes\/methods starting with a single underscore (e.g., <code>_protected_attribute<\/code>). This is a convention, meaning \"don't directly access this from outside the class unless you know what you are doing.\" Python does not strictly prevent access.<\/li>\n\n\n\n<li><strong>Private:<\/strong> Attributes\/methods starting with two underscores (e.g., <code>__private_attribute<\/code>). Python \"mangles\" these names to make them harder to access directly from outside the class.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nclass BankAccount:\n    def __init__(self, initial_balance):\n        self.__balance = initial_balance # Private attribute\n\n    def deposit(self, amount):\n        if amount &gt; 0:\n            self.__balance += amount\n            print(f&quot;Deposited {amount}. New balance: {self.__balance}&quot;)\n        else:\n            print(&quot;Deposit amount must be positive.&quot;)\n\n    def withdraw(self, amount):\n        if amount &gt; 0 and self.__balance &gt;= amount:\n            self.__balance -= amount\n            print(f&quot;Withdrew {amount}. New balance: {self.__balance}&quot;)\n        else:\n            print(&quot;Invalid withdrawal amount or insufficient funds.&quot;)\n\n    def get_balance(self):\n        return self.__balance\n\n# Create a bank account object\nmy_account = BankAccount(1000)\n\n# Interact with the account using public methods\nmy_account.deposit(200)\nmy_account.withdraw(500)\nprint(f&quot;Current balance: {my_account.get_balance()}&quot;)\n\n# Trying to access a &quot;private&quot; attribute directly (Python name mangles it)\n# print(my_account.__balance) # This will cause an AttributeError\n<\/pre><\/div>\n\n\n<p>This code outputs:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nDeposited 200. New balance: 1200\nWithdrew 500. New balance: 700\nCurrent balance: 700\n<\/pre><\/div>\n\n\n<p>You manage the <code>__balance<\/code> (private data) through <code>deposit()<\/code>, <code>withdraw()<\/code>, and <code>get_balance()<\/code> methods. This prevents direct, uncontrolled changes to the balance.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"5-polymorphism\">5. Polymorphism<\/h2>\n\n\n\n<p><strong>Polymorphism<\/strong> means \"many forms.\" It lets you use the same function name for different types of objects. This means one function or method can act in many forms.<\/p>\n\n\n\n<p>Think of a <code>speak()<\/code> method. A <code>Dog<\/code> object might <code>speak()<\/code> by barking, while a <code>Cat<\/code> object might <code>speak()<\/code> by meowing. The method name is the same, but the behavior is different based on the object type.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nclass Dog:\n    def speak(self):\n        print(&quot;Woof!&quot;)\n\nclass Cat:\n    def speak(self):\n        print(&quot;Meow!&quot;)\n\nclass Duck:\n    def speak(self):\n        print(&quot;Quack!&quot;)\n\n# Function that takes an animal object and makes it speak\ndef make_animal_speak(animal):\n    animal.speak()\n\n# Create animal objects\nmy_dog = Dog()\nmy_cat = Cat()\nmy_duck = Duck()\n\n# Call the same function with different animal objects\nmake_animal_speak(my_dog)\nmake_animal_speak(my_cat)\nmake_animal_speak(my_duck)\n<\/pre><\/div>\n\n\n<p>This code outputs:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nWoof!\nMeow!\nQuack!\n<\/pre><\/div>\n\n\n<p>The <code>make_animal_speak()<\/code> function does not care what type of animal it receives. It just calls the <code>speak()<\/code> method, and the correct <code>speak()<\/code> method for that animal runs. This makes your code more flexible.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"6-abstraction\">6. Abstraction<\/h2>\n\n\n\n<p><strong>Abstraction<\/strong> means showing only the essential features of an object and hiding complex implementation details. It lets you focus on what an object does, not how it does it.<\/p>\n\n\n\n<p>Imagine driving a car. You use the steering wheel, pedals, and gear stick. You do not need to know the complex mechanics of the engine or transmission. Abstraction hides these details.<\/p>\n\n\n\n<p>In Python, you can achieve abstraction using abstract classes and methods. An abstract class cannot be created directly. It provides a blueprint that other classes must follow. The <code>abc<\/code> module (Abstract Base Classes) helps you do this.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nfrom abc import ABC, abstractmethod\n\nclass Shape(ABC): # Shape is an abstract base class\n    @abstractmethod\n    def area(self):\n        pass # Abstract method - must be implemented by child classes\n\n    @abstractmethod\n    def perimeter(self):\n        pass # Abstract method\n\nclass Circle(Shape):\n    def __init__(self, radius):\n        self.radius = radius\n\n    def area(self):\n        return 3.14 * self.radius * self.radius\n\n    def perimeter(self):\n        return 2 * 3.14 * self.radius\n\nclass Square(Shape):\n    def __init__(self, side):\n        self.side = side\n\n    def area(self):\n        return self.side * self.side\n\n    def perimeter(self):\n        return 4 * self.side\n\n# Create objects\nmy_circle = Circle(5)\nmy_square = Square(4)\n\n# Calculate and print\nprint(f&quot;Circle area: {my_circle.area()}&quot;)\nprint(f&quot;Square perimeter: {my_square.perimeter()}&quot;)\n\n# Trying to create an abstract class directly will raise an error\n# abstract_shape = Shape() # This would give a TypeError\n<\/pre><\/div>\n\n\n<p>This code outputs:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nCircle area: 78.5\nSquare perimeter: 16\n<\/pre><\/div>\n\n\n<p>The <code>Shape<\/code> class defines <code>area()<\/code> and <code>perimeter()<\/code> as abstract methods. Any class inheriting from <code>Shape<\/code> must implement these methods. You focus on the idea of a <code>Shape<\/code> having an area and perimeter, not the exact calculation method.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>OOP concepts in Python help you write organized, reusable, and flexible code. Understanding classes and objects lets you model real-world problems in your programs. Inheritance helps you reuse code. Encapsulation protects your data. Polymorphism makes your code adaptable. Abstraction simplifies complex systems.<\/p>\n\n\n\n<p>Understanding OOP concepts is a major milestone in your journey to becoming a developer. However, if any of these topics still feel a bit complex, remember that every expert started with the basics. To ensure you have a rock-solid foundation in Python, we recommend trying our Free Python Course. It is tailored for beginners to help them move from zero coding experience to writing functional scripts, making it the perfect stepping stone to the advanced concepts covered in this guide<\/p>\n\n\n\n\n    <div class=\"courses-cta-container\">\n        <div class=\"courses-cta-card\">\n            <div class=\"courses-cta-header\">\n                <div class=\"courses-learn-icon\"><\/div>\n                <span class=\"courses-learn-text\">Free Course<\/span>\n            <\/div>\n            <p class=\"courses-cta-title\">\n                <a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/python-fundamentals-for-beginners\" class=\"courses-cta-title-link\">Python Fundamentals for Beginners Free Course<\/a>\n            <\/p>\n            <p class=\"courses-cta-description\">Master Python basics, from variables to data structures and control flow. Solve real-time problems and build practical skills using Jupyter Notebook.<\/p>\n            <div class=\"courses-cta-stats\">\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-user-icon\"><\/div>\n                    <span>13.5 hrs<\/span>\n                <\/div>\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-star-icon\"><\/div>\n                    <span>4.55<\/span>\n                <\/div>\n            <\/div>\n            <a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/python-fundamentals-for-beginners\" class=\"courses-cta-button\">\n                Enroll for Free\n                <div class=\"courses-arrow-icon\"><\/div>\n            <\/a>\n        <\/div>\n    <\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Object-Oriented Programming (OOP) is a way of organizing your code. It lets you create programs that are easy to understand and manage. In Python, OOP uses \"objects\" to represent real-world things or ideas. These objects combine data and the actions that can be performed on that data. Using OOP helps you write code that is [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":31908,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[36796],"content_type":[],"class_list":["post-47857","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-python"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Learn Object-Oriented Programming in Python<\/title>\n<meta name=\"description\" content=\"Learn Object-Oriented Programming (OOP) concepts in Python. Understand how these concepts help in building clean and efficient Python programs.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"OOPs Concepts in Python\" \/>\n<meta property=\"og:description\" content=\"Learn Object-Oriented Programming (OOP) concepts in Python. Understand how these concepts help in building clean and efficient Python programs.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-25T00:39:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-11T22:12:35+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1255\" \/>\n\t<meta property=\"og:image:height\" content=\"836\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-python\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-python\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"OOPs Concepts in Python\",\"datePublished\":\"2021-10-25T00:39:47+00:00\",\"dateModified\":\"2025-06-11T22:12:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-python\\\/\"},\"wordCount\":971,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/iStock-1139255812.jpg\",\"keywords\":[\"python\"],\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-python\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-python\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-python\\\/\",\"name\":\"Learn Object-Oriented Programming in Python\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-python\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/iStock-1139255812.jpg\",\"datePublished\":\"2021-10-25T00:39:47+00:00\",\"dateModified\":\"2025-06-11T22:12:35+00:00\",\"description\":\"Learn Object-Oriented Programming (OOP) concepts in Python. Understand how these concepts help in building clean and efficient Python programs.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-python\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-python\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-python\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/iStock-1139255812.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/iStock-1139255812.jpg\",\"width\":1255,\"height\":836,\"caption\":\"Python Programming Language on server room background. Programing workflow abstract algorithm concept on virtual screen.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-python\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IT\\\/Software Development\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/software\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"OOPs Concepts in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Learn Object-Oriented Programming in Python","description":"Learn Object-Oriented Programming (OOP) concepts in Python. Understand how these concepts help in building clean and efficient Python programs.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/","og_locale":"en_US","og_type":"article","og_title":"OOPs Concepts in Python","og_description":"Learn Object-Oriented Programming (OOP) concepts in Python. Understand how these concepts help in building clean and efficient Python programs.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2021-10-25T00:39:47+00:00","article_modified_time":"2025-06-11T22:12:35+00:00","og_image":[{"width":1255,"height":836,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812.jpg","type":"image\/jpeg"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"OOPs Concepts in Python","datePublished":"2021-10-25T00:39:47+00:00","dateModified":"2025-06-11T22:12:35+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/"},"wordCount":971,"commentCount":0,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812.jpg","keywords":["python"],"articleSection":["IT\/Software Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/","url":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/","name":"Learn Object-Oriented Programming in Python","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812.jpg","datePublished":"2021-10-25T00:39:47+00:00","dateModified":"2025-06-11T22:12:35+00:00","description":"Learn Object-Oriented Programming (OOP) concepts in Python. Understand how these concepts help in building clean and efficient Python programs.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812.jpg","width":1255,"height":836,"caption":"Python Programming Language on server room background. Programing workflow abstract algorithm concept on virtual screen."},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"IT\/Software Development","item":"https:\/\/www.mygreatlearning.com\/blog\/software\/"},{"@type":"ListItem","position":3,"name":"OOPs Concepts in Python"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812.jpg",1255,836,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812-150x150.jpg",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812-300x200.jpg",300,200,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812-768x512.jpg",768,512,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812-1024x682.jpg",1024,682,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812.jpg",1255,836,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812.jpg",1255,836,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812-640x836.jpg",640,836,true],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812-96x96.jpg",96,96,true],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/04\/iStock-1139255812-150x100.jpg",150,100,true]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"Object-Oriented Programming (OOP) is a way of organizing your code. It lets you create programs that are easy to understand and manage. In Python, OOP uses \"objects\" to represent real-world things or ideas. These objects combine data and the actions that can be performed on that data. Using OOP helps you write code that is&hellip;","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/47857","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=47857"}],"version-history":[{"count":6,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/47857\/revisions"}],"predecessor-version":[{"id":116955,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/47857\/revisions\/116955"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/31908"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=47857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=47857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=47857"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=47857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}