Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
43 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to OOPs in Python- a quick guide.

(Ref : https://www.analyticsvidhya.com/blog/2020/09/object-oriented-programming/ Accessed on 21st June 2022) . This is a practise project for documentation and texts here are borrowed from the above references.

Object Oriented Programming concepts in Python:

  1. :ref:`Class`
  2. :ref:`Object`
  3. :ref:`Method`
  4. :ref:`Inheritance`
  5. :ref:`Encapsulation`
  6. :ref:`Polymorphism`
  7. :ref:`Data abstraction`

What is a class?

Classes are user defined data structures (contrast with primitive data types-Integers,Float,Strings,Boolean) . It is also blueprint for creating many objects each with custom values. Let's begin with creating a car class without any details :

class Car:
        pass

Now let's add name , color as we expect real world Sedan car to have one through class constructor _init_ :

class Car:
        car_type = "Sedan"          #class attribute - common to all objects.
        def __init__(self, name, color):
                self.name = name    #instance attribute -each instance may have different value.
                self.color = color  #instance attribute -each instance may have different value.

Object and object instantiation

Creating a particular instance for a red Honda City.

obj1 = Car("Honda City","Red")

Creating another instance for a blue Maruti Dzire.

obj2 = Car("Maruti Dzire","Blue")

Objects as instances of a class.

Class methods

Inheritance in Python Class

Encapsulation

Polymorphism

Data abstraction

.. toctree::
   :maxdepth: 2
   :caption: Contents:



About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.