Object oriented Programming Language (OOPS)
Object-Oriented Programming System (OOPS) एक ऐसी Programming Technique है जिसमें Program को Class और Object की मदद से बनाया जाता है। इसमें किसी Object की जानकारी Data और उस पर होने वाले काम Functions/Methods को एक साथ रखा जाता है। इससे Program को समझना, लिखना, बदलना और दोबारा उपयोग करना आसान हो जाता है। OOPS Real World की चीज़ों जैसे Student, Car, Mobile, Bank Account आदि को Program में दर्शाता है। Python में OOPS का उपयोग बड़े Software और Applications बनाने के लिए किया जाता है। OOPS के चार मुख्य सिद्धांत हैं: Encapsulation, Inheritance, Polymorphism और Abstraction।
Characteristics of OOPS
1. Class and Object Based Programming
OOPS में पूरा Program Class और Object के basis पर बनाया जाता है। Class एक Blueprint होती है, जबकि Object उसका वास्तविक रूप (Instance) होता है।
Example :
- Class → Car
- Object → Maruti Swift, Tata Nexon
2. Encapsulation
Encapsulation का अर्थ है Data (Variables) और Methods (Functions) को एक ही Class के अंदर रखना। इससे Data सुरक्षित रहता है और उसे सीधे Access नहीं किया जा सकता है।
Example :
Bank Account का Balance केवल deposit() और withdraw() Method से बदला जा सकता है।
3. Data Hiding
OOPS में महत्वपूर्ण Data को बाहरी व्यक्ति से छिपाया जा सकता है। इससे Data की Security बढ़ जाती है।
Example :
ATM का PIN सीधे दिखाई नहीं देता, बल्कि Password की तरह छिपा रहता है।
4. Inheritance
Inheritance की सहायता से एक Class दूसरी Class की Properties और Methods को प्राप्त कर सकती है। इससे Code दोबारा लिखने की आवश्यकता नहीं होती।
Example :Vehicle Class के start() Method का उपयोग Car और Bike दोनों कर सकते हैं।
5. Polymorphism
Polymorphism का अर्थ है कि एक ही Method अलग-अलग Objects के लिए अलग-अलग कार्य कर सकता है।
Example :sound() Method:
- Dog → Bark
- Cat → Meow
6. Abstraction
Abstraction में केवल आवश्यक जानकारी (Essential Information) दिखाई जाती है और जटिल प्रक्रिया (Implementation) छिपाई जाती है।
Example :
Car चलाते समय Driver केवल Steering, Brake और Accelerator का उपयोग करता है। Engine के अंदर क्या हो रहा है, यह जानना आवश्यक नहीं होता।
7. Code Reusability
OOPS में एक बार लिखा गया Code कई स्थानों पर उपयोग किया जा सकता है। इससे समय और मेहनत दोनों की बचत होती है।
Example :
यदि Login Module पहले से बना हुआ है, तो उसे नए Project में भी उपयोग किया जा सकता है।
8. Modularity
OOPS में बड़े Program को छोटे-छोटे Modules (Classes) में बाँटा जाता है। इससे Program को समझना, बदलना और Maintain करना आसान हो जाता है।
Example :
School Management System में अलग-अलग Classes:
- Student
- Teacher
- Library
- Fee
Features of OOPS
1. Class
Class एक Blueprint होती है, जिससे Objects बनाए जाते हैं। इसमें Data (Variables) और Methods (Functions) को एक साथ Define किया जाता है। Class स्वयं Memory नहीं लेती, बल्कि जब इसका Object बनाया जाता है तब Memory Allocate होती है। एक Class से कई Objects बनाए जा सकते हैं।
Example :
# Class Example
class Student:
def show(self):
print("Welcome to Python OOPS")
# Object Create
s = Student()
# Method Call
s.show()
2. Object
Object किसी Class का वास्तविक रूप (Instance) होता है। जब Class से Object बनाया जाता है, तब Memory Allocate होती है। Object, Class के Variables और Methods का उपयोग करता है। एक Class से कई Objects बनाए जा सकते हैं और प्रत्येक Object का अपना अलग Data एवं पहचान (Identity) हो सकती है।
Example :
# Object Example
class Student:
def show(self):
print("Welcome to Python OOPS")
# Object Create
s1 = Student()
s2 = Student()
# Method Call
s1.show()
s2.show()
3. Encapsulation
Encapsulation OOPS का एक महत्वपूर्ण Feature है, जिसमें Data (Variables) और Methods (Functions) को एक ही Class के अंदर रखा जाता है। साथ ही, महत्वपूर्ण Data को सीधे (Directly) Access करने से रोका जाता है। इससे Data Security, Data Hiding और Easy Maintenance प्राप्त होती है।
Example :
# Encapsulation Example
class Student:
def __init__(self):
self.__marks = 90 # Private Variable
def showMarks(self):
print("Marks =", self.__marks)
# Object Create
s = Student()
# Method Call
s.showMarks()
4. Inheritance
Inheritance OOPS का एक महत्वपूर्ण Feature है, जिसमें एक Class (Child Class) दूसरी Class (Parent Class) की Properties (Variables) और Methods (Functions) को प्राप्त (Inherit) करती है। इससे Code को दोबारा लिखने की आवश्यकता नहीं होती, Code Reusability बढ़ती है और Program को Develop तथा Maintain करना आसान हो जाता है।
Example :
# Inheritance Example
# Parent Class
class Vehicle:
def start(self):
print("Vehicle Started")
# Child Class
class Car(Vehicle):
def drive(self):
print("Car is Running")
# Object Create
c = Car()
# Parent Class Method
c.start()
# Child Class Method
c.drive()
Types of inheritance
1. Single inheritance
जब एक Child Class केवल एक Parent Class से Properties और Methods प्राप्त करती है, तो उसे Single Inheritance कहते हैं।
Example :
# Single Inheritance
class Animal:
def sound(self):
print("Animal makes sound")
class Dog(Animal):
def bark(self):
print("Dog Barks")
d = Dog()
d.sound()
d.bark()
2. Multiple Inheritance
जब एक Child Class एक से अधिक Parent Classes से Properties और Methods प्राप्त करती है, तो उसे Multiple Inheritance कहते हैं।
Example :
# Multiple Inheritance
class Father:
def money(self):
print("Father has Money")
class Mother:
def care(self):
print("Mother takes Care")
class Son(Father, Mother):
pass
s = Son()
s.money()
s.care()
3. Multilevel Inheritance
जब एक Child Class दूसरी Child Class की Parent बन जाती है, तो उसे Multilevel Inheritance कहते हैं।
Example :
# Multilevel Inheritance
class Animal:
def eat(self):
print("Animal Eats")
class Dog(Animal):
def bark(self):
print("Dog Barks")
class Puppy(Dog):
def play(self):
print("Puppy Plays")
p = Puppy()
p.eat()
p.bark()
p.play()
4. Hierarchical Inheritance
जब एक Parent Class से कई Child Classes बनती हैं, तो उसे Hierarchical Inheritance कहते हैं।
Example :
# Hierarchical Inheritance
class Animal:
def eat(self):
print("Animal Eats")
class Dog(Animal):
def bark(self):
print("Dog Barks")
class Cat(Animal):
def meow(self):
print("Cat Meows")
d = Dog()
c = Cat()
d.eat()
d.bark()
c.eat()
c.meow()
5. Hybrid Inheritance
जब दो या दो से अधिक Inheritance Types को मिलाकर उपयोग किया जाता है, तो उसे Hybrid Inheritance कहते हैं।
Example :
# Hybrid Inheritance
class A:
def displayA(self):
print("Class A")
class B(A):
def displayB(self):
print("Class B")
class C(A):
def displayC(self):
print("Class C")
class D(B, C):
def displayD(self):
print("Class D")
obj = D()
obj.displayA()
obj.displayB()
obj.displayC()
obj.displayD()
5. Polymorphism
Polymorphism OOPS का एक महत्वपूर्ण Feature है, जिसका अर्थ है “One Interface, Many Forms” (एक कार्य, कई रूप)। इसमें एक ही Method अलग-अलग Objects के लिए अलग-अलग तरीके से कार्य करता है। इससे Program अधिक Flexible, Reusable और Easy to Maintain बनता है।
Example :
# Polymorphism Example
class Dog:
def sound(self):
print("Dog says: Bark")
class Cat:
def sound(self):
print("Cat says: Meow")
class Cow:
def sound(self):
print("Cow says: Moo")
# Object Create
d = Dog()
c = Cat()
w = Cow()
# Method Call
d.sound()
c.sound()
w.sound()
Types of Polymorphism
1. Compile-time polymorphism (Static Polymorphism)
जब किसी Method का व्यवहार Program Compile होने से पहले तय हो जाता है, तो उसे Compile-time Polymorphism कहते हैं। Python में Method Overloading सीधे Support नहीं करता, इसलिए इसे Default Arguments या *args का उपयोग करके प्राप्त किया जाता है।
Example :
# Compile-time Polymorphism using Default Argument
class Calculator:
def add(self, a, b=0):
print("Sum =", a + b)
c = Calculator()
c.add(10)
c.add(10, 20)
2. Run-time polymorphism (Dynamic Polymorphism)
जब किसी Method का व्यवहार Program Run होने के समय तय होता है, तो उसे Run-time Polymorphism कहते हैं। इसे Method Overriding द्वारा प्राप्त किया जाता है। Child Class, Parent Class के Method को अपनी आवश्यकता के अनुसार बदल सकती है।
Example :
# Run-time Polymorphism (Method Overriding)
class Animal:
def sound(self):
print("Animal Sound")
class Dog(Animal):
def sound(self):
print("Dog Barks")
class Cat(Animal):
def sound(self):
print("Cat Meows")
d = Dog()
c = Cat()
d.sound()
c.sound()
6. Data Abstraction
Data Abstraction OOPS का एक महत्वपूर्ण Feature है, जिसमें केवल आवश्यक (Essential) जानकारी को User को दिखाया जाता है और अनावश्यक या जटिल Implementation Details को छिपाया जाता है। इससे Program सरल, सुरक्षित (Secure) और उपयोग में आसान (Easy to Use) बनता है।
Example :
# Data Abstraction Example
from abc import ABC, abstractmethod
# Abstract Class
class Shape(ABC):
@abstractmethod
def area(self):
pass
# Child Class
class Circle(Shape):
def area(self):
print("Area of Circle")
# Object Create
c = Circle()
# Method Call
c.area()
7. Message Passing
Message Passing OOPS का एक महत्वपूर्ण Feature है, जिसमें एक Object दूसरे Object के साथ Method Call के माध्यम से Communication (संदेश का आदान-प्रदान) करता है। अर्थात एक Object दूसरे Object को कोई कार्य करने के लिए Message भेजता है। इससे Program अधिक Modular, Organized और Reusable बनता है।
Example :
# Message Passing Example
class Teacher:
def teach(self):
print("Teacher is Teaching Python")
class Student:
def learn(self, teacher):
teacher.teach()
# Object Create
t = Teacher()
s = Student()
# Message Passing
s.learn(t)
- इसे भी पढ़े : C Programming in hindi
- इसे भी पढ़े : C++ Programming in hindi
- Python Full Course Roadmap 2026Python Introduction↓Python Installation & Setup↓Python Basics↓Variables & Data Types↓Operators↓Conditional Statements↓Loops↓Functions↓Data Structures↓File Handling↓Exception Handling↓Object Oriented Programming (OOP)↓Modules & Libraries↓Advanced Python↓Database Connectivity↓Web Development↓Data Science & AI↓Automation & Projects↓Python Developer
- What is Python in Hindi (Basic to advanced)Introduction and History Introduction for Python Python History Python Features Python Applications Applications Uses 1. Artificial Intelligence (AI) and Machine Learning Python का उपयोग AI models, Machine Learning algorithms, Chatbots, Face Recognition, Voice Assistant और Prediction systems बनाने के लिए किया जाता है। 2. Data Science and Data Analysis Python से बड़े datasets को analyze… Read more: What is Python in Hindi (Basic to advanced)
- Python Keywords in Hindi (easy to understand )Python Keywords में ऐसे special word होते हैं जिनका Python भाषा में पहले से एक Predefined meaning होता है। Python Interpreter इन words को पहचानता है और इनके अनुसार कार्य करता है। Example : No. Keyword हिंदी में अर्थ Uses (उपयोग) Syntax 1 False गलत False keywords का use Boolean False value के लिए किया… Read more: Python Keywords in Hindi (easy to understand )
- Python Variables in Hindi (Easy to understand)what is Variable Assigning Value to variable Source Code : Output : 5 Hello [2, 5, 9] Changing Variable’s Values Source Code : Output : 5Hello[4, 5, 8] Assigning Single Value to Multiple Variables Source Code : Output : HelloHelloHelloHello Assigning Value to Variable according to order Source Code : Output : 1H[1, 2] Variable… Read more: Python Variables in Hindi (Easy to understand)
- Python Data Types in Hindi (easy to understand)Python में Data Type यह बताता है कि किसी variable में किस प्रकार का data store है। Python में data type को manually declare नहीं करना पड़ता, Python interpreter value देखकर data type पहचान लेता है। Example : Number Python में Number Data Types का उपयोग संख्याओं (Numbers) को store और process करने के लिए… Read more: Python Data Types in Hindi (easy to understand)
