DEV Community

Lakshmi Pritha Nadesan
Lakshmi Pritha Nadesan

Posted on

1

Day 18 - Object Oriented Programming

Object Oriented Programming(OOPS):

OOPS stands for Object-Oriented Programming System, which is a programming paradigm based on the concept of objects.

Class:

A blueprint or template for creating objects.
Class represent logical entities.

Object:

An object is representation of a class.
Objects represent real-world entities or real time entities.
Objects has states and behavior.

we cannot create object without class.But class can be present without objects.

Example with Bike:

The Bike class defines what a bike is and what it can do.
States like brand, color, and speed describe the bike.
Behavior like start, accelerate, and stop define actions a bike can perform.
Activa and Scooter are objects of the Bike class.
Each object represents a real bike with specific states (e.g., brand and color) and behaviors.

Example:

import calculator
#Object Creation
calc=calculator()
Enter fullscreen mode Exit fullscreen mode

Here calculator is a class and calc is a object.

Encapsulation:

Encapsulation is the bundling of data (attributes) and methods that operate on the data within one unit (class). It also restricts direct access to some components of the object.

Public, Protected, and Private Attributes:

Public:Accessible everywhere (self.name).

Protected:Accessible in the class and subclasses (self._name).

Private: Accessible only within the class (self.__name).

Example:

class company:
    def __research():
        pass
    def __give_salary():
        pass

co=company()
co.__research()

Enter fullscreen mode Exit fullscreen mode

__ is the special symbol called docker.

Python is multi paradigm Programming language.
Python supports
1.Object Oriented Programming
2.Functional programming
3.Modular Programming
4.Procedure oriented Programming

C# supports object oriented programming.
Java and JS supports object oriented programming and functional programming.

Interpreter, compiler and OS written by C language. That supports procedure oriented programming.

We can install the module using the following commend:

sudo apt install python3-modulename

Example for emoji module:

import emoji
result = emoji.emojize('Python is :thumbs_up:')
print(result)

# You can also reverse this:
result = emoji.demojize('Python is 👍')
print(result)

Enter fullscreen mode Exit fullscreen mode
Python is 👍
Python is :thumbs_up:
Enter fullscreen mode Exit fullscreen mode

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay