- Home
- Course Detail
regularpython@gmail.com
You are now watching:
Python Basics in English / of Overview of the OOPS concept
Overview of OOPS Concept in Python
1. What is OOPS?
Object-Oriented Programming System (OOPS) is a programming method that organizes code using objects and classes. It helps in building clean, reusable, scalable, and maintainable applications.
•
OOPS is used in real-time applications such as banking systems, payment apps, web applications, e‑commerce, and automation frameworks.
•
Focuses on modularity, code reusability, and security.
2. Key OOPS Concepts
A. Class
A class is a blueprint/template for creating objects.
class Student:
def __init__(self, name, marks):
self.name = name
self.marks = marks
B. Object
An object is an instance of a class.
s = Student("Sai", 90)
C. Encapsulation
Binding data (variables) and methods into a single unit (class). Also hides internal details.
class Bank:
def __init__(self):
self.__balance = 0 # private variable
def deposit(self, amount):
self.__balance += amount
D. Inheritance
One class acquiring properties/methods of another class.
class Animal:
def sound(self):
print("Some sound")
class Dog(Animal):
def sound(self):
print("Bark")
E. Polymorphism
Same method name behaving differently based on the object.
def make_sound(animal):
animal.sound()
F. Abstraction
Hiding complex logic and showing only the necessary details. Achieved using abstract classes.
from abc import ABC, abstractmethod
class Car(ABC):
@abstractmethod
def start(self):
pass
3. Why OOPS is Used in Real-Time Projects?
✔
To build large-scale, maintainable applications.
✔
To reuse common logic across teams and modules.
✔
To keep code modular, secure, and easy to update.
✔
To represent real‑world entities like Users, Employees, Payments, Vehicles, Orders, etc.
4. Real-Time Example – E‑Commerce Order System
This is how OOPS is applied in a real application:
➡
Class: User – Stores user details
➡
Class: Order – Stores order details
➡
Class: Payment – Abstract class for payments
➡
Class: UpiPayment / CardPayment – Implements make_payment()
class User:
def __init__(self, name):
self.name = name
class Order:
def __init__(self, user, amount):
self.user = user
self.amount = amount
# Polymorphism Example
class Payment:
def pay(self):
pass
class UpiPayment(Payment):
def pay(self):
print("Paid using UPI")
class CardPayment(Payment):
def pay(self):
print("Paid using Card")
# Runtime Polymorphism
payment = UpiPayment()
payment.pay()
5. Summary of OOPS
•
OOPS helps build structured, reusable, secure applications.
•
Main concepts: Class, Object, Encapsulation, Inheritance, Polymorphism, Abstraction.
•
Used in all real-time Python applications.