Skip to content

pranoyghosh35/OOPsinPython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

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

No releases published

Packages

 
 
 

Contributors