{"id":101,"date":"2026-03-02T07:39:17","date_gmt":"2026-03-02T02:39:17","guid":{"rendered":"https:\/\/gigz.pk\/python\/?post_type=lesson&#038;p=101"},"modified":"2026-03-15T17:02:50","modified_gmt":"2026-03-15T12:02:50","slug":"what-is-oop","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/python\/lesson\/what-is-oop\/","title":{"rendered":"What is OOP?"},"content":{"rendered":"\n<p>Object-Oriented Programming (OOP) is a programming concept based on objects and classes.<\/p>\n\n\n\n<p>It is used to organize code into reusable and structured components.<\/p>\n\n\n\n<p>In simple words:<br>OOP allows you to model real-world things (like a car, student, bank account) into code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>KEY CONCEPTS OF OOP<\/strong><\/h2>\n\n\n\n<p>There are four main principles of OOP:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Encapsulation<\/li>\n\n\n\n<li>Abstraction<\/li>\n\n\n\n<li>Inheritance<\/li>\n\n\n\n<li>Polymorphism<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1. CLASS<\/strong><\/h2>\n\n\n\n<p>A class is a blueprint for creating objects.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class Student:<br>    pass<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2. OBJECT<\/strong><\/h2>\n\n\n\n<p>An object is an instance of a class.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class Student:<br>    passs1 = Student()<br>print(type(s1))<\/pre>\n\n\n\n<p>Here, <code>s1<\/code> is an object of the <code>Student<\/code> class.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>REAL-WORLD EXAMPLE<\/strong><\/h2>\n\n\n\n<p>Think of a class as a blueprint of a house.<br>An object is the actual house built from that blueprint.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>WHY USE OOP?<\/strong><\/h2>\n\n\n\n<p>\u2022 Organizes large programs<br>\u2022 Makes code reusable<br>\u2022 Improves readability<br>\u2022 Helps manage complex projects<br>\u2022 Used in real-world applications<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>SIMPLE EXAMPLE WITH ATTRIBUTES<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">class Student:<br>    def __init__(self, name, age):<br>        self.name = name<br>        self.age = ages1 = Student(\"Hira\", 22)print(s1.name)<br>print(s1.age)<\/pre>\n\n\n\n<p>Here:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>__init__<\/code> is a constructor<\/li>\n\n\n\n<li><code>self<\/code> refers to the current object<\/li>\n\n\n\n<li><code>name<\/code> and <code>age<\/code> are attributes<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>EXAMPLE WITH METHODS<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">class Student:<br>    def __init__(self, name):<br>        self.name = name    def greet(self):<br>        print(\"Hello, my name is\", self.name)s1 = Student(\"Ali\")<br>s1.greet()<\/pre>\n\n\n\n<p>Methods are functions inside a class.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>OOP VS PROCEDURAL PROGRAMMING<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Procedural<\/th><th>OOP<\/th><\/tr><\/thead><tbody><tr><td>Uses functions<\/td><td>Uses classes &amp; objects<\/td><\/tr><tr><td>Less structured for big projects<\/td><td>Highly structured<\/td><\/tr><tr><td>Harder to maintain large systems<\/td><td>Easier to manage large systems<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>WHERE OOP IS USED<\/strong><\/h2>\n\n\n\n<p>\u2022 Web development<br>\u2022 Game development<br>\u2022 Desktop applications<br>\u2022 Mobile apps<br>\u2022 Enterprise software<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>KEY TAKEAWAY<\/strong><\/h2>\n\n\n\n<p>OOP is a programming approach that uses classes and objects to structure code in a clear, reusable, and real-world manner.<\/p>\n\n\n\n<p>It is one of the most important concepts in Python and modern programming.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/python\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">OBJECT ORIENTED PROGRAMMING IN PYTHON (OOP) > OOP Basics > What is OOP?<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1773464981775\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<p><\/p>\n","protected":false},"menu_order":46,"template":"","class_list":["post-101","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What is OOP? - One Language. Endless Possibilities<\/title>\n<meta name=\"description\" content=\"Learn Python OOP: classes, objects, methods, inheritance, and polymorphism. Organize code efficiently for real-world applications.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/python\/lesson\/what-is-oop\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is OOP? - One Language. Endless Possibilities\" \/>\n<meta property=\"og:description\" content=\"Learn Python OOP: classes, objects, methods, inheritance, and polymorphism. Organize code efficiently for real-world applications.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/python\/lesson\/what-is-oop\/\" \/>\n<meta property=\"og:site_name\" content=\"One Language. Endless Possibilities\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-15T12:02:50+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/what-is-oop\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/what-is-oop\\\/\",\"name\":\"What is OOP? - One Language. Endless Possibilities\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\"},\"datePublished\":\"2026-03-02T02:39:17+00:00\",\"dateModified\":\"2026-03-15T12:02:50+00:00\",\"description\":\"Learn Python OOP: classes, objects, methods, inheritance, and polymorphism. Organize code efficiently for real-world applications.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/what-is-oop\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/what-is-oop\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/what-is-oop\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"OBJECT ORIENTED PROGRAMMING IN PYTHON (OOP) > OOP Basics > What is OOP?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\",\"name\":\"One Language. Endless Possibilities\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/python\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is OOP? - One Language. Endless Possibilities","description":"Learn Python OOP: classes, objects, methods, inheritance, and polymorphism. Organize code efficiently for real-world applications.","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:\/\/gigz.pk\/python\/lesson\/what-is-oop\/","og_locale":"en_US","og_type":"article","og_title":"What is OOP? - One Language. Endless Possibilities","og_description":"Learn Python OOP: classes, objects, methods, inheritance, and polymorphism. Organize code efficiently for real-world applications.","og_url":"https:\/\/gigz.pk\/python\/lesson\/what-is-oop\/","og_site_name":"One Language. Endless Possibilities","article_modified_time":"2026-03-15T12:02:50+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/python\/lesson\/what-is-oop\/","url":"https:\/\/gigz.pk\/python\/lesson\/what-is-oop\/","name":"What is OOP? - One Language. Endless Possibilities","isPartOf":{"@id":"https:\/\/gigz.pk\/python\/#website"},"datePublished":"2026-03-02T02:39:17+00:00","dateModified":"2026-03-15T12:02:50+00:00","description":"Learn Python OOP: classes, objects, methods, inheritance, and polymorphism. Organize code efficiently for real-world applications.","breadcrumb":{"@id":"https:\/\/gigz.pk\/python\/lesson\/what-is-oop\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/python\/lesson\/what-is-oop\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/python\/lesson\/what-is-oop\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/python\/"},{"@type":"ListItem","position":2,"name":"OBJECT ORIENTED PROGRAMMING IN PYTHON (OOP) > OOP Basics > What is OOP?"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/python\/#website","url":"https:\/\/gigz.pk\/python\/","name":"One Language. Endless Possibilities","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/python\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson\/101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/media?parent=101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}