Python Classes and Objects In Hindi

Python Oops – Python Classes and Objects In Hindi

Python

Python Classes and Objects In Hindi:- Ham Is Post Mai Learn Karne Wale Hai Ki Python Class In Hindi And Python Objects In Hindi Kiya Hote Hai|

Python Object-Oriented Programming Language Hai Or Python OOPs Concepts In Hindi Mai 2 Prakar ke program paradigm ka use Kiya Jata Hai | Yah “Procedure Oriented” Or “Object-oriented programming” Hai | Aaj Ke Time Ki Sabhi  programming languages Object-oriented programming Ko Istemal Karti Hai |

Python Classes and Objects In Hindi

Python Oops In Hindi - Python Classes and Objects In Hindi

Jyada tar Programming Languages Mai OOP ka Concept Hota Hai | Python Ke Object Mai Variables, Functions Ya Method Hote Hai |

For Example Agar Koi Car Hai To Us Car Ke Parts Or Color, Model Etc Ko Variables Or Functions Ya Methods Ke Jariye Likha Jata Hai |

What Is Class In Hindi

Class Ek user-defined data type hai | ye C language mei structure ki Tarah hi Hota hai | Lekin classes mei Aap variable ke sath sath unse related functions Bhi Bana Sakte hai | Jinhe Aap bad mei objects ke duvara access kiya ja sakta hai |

Python Mai Class Ko Create Karne Ke Liye Class Keyword Ka Istemal Kiya Jata Hai |

Class Definition Syntax:

class ClassName:
    # Statement-1
    .
    .
    .
    # Statement-N

Defining a class –

class Car: 
    pass

Aap upper Diye Gaye Code Ko Dekh Sakte Hai Hamne Ek Class Car Ke Name Create Kiya Hai Or Us Class Car Ke Under Pass Statement Lagaya Hai Joki Ye Dikhata Hai Ki Class Car Ke Under Kuch Bhi Nhi Hai |

Example

class Car:
  x = "ALTO"

Aap upper Diye Gaye Code Ko Dekh Sakte Hai Hamne Ek Class Car Ke Name Create Kiya Hai Or Us Class Car Ke Under Ek Variable x Banaya Hai |

Creating an Object in Python

Python Object Ko Variable Ke Rup Mai Hi Create Kiya Jata Hai | Us Variable Ko Ham Function Ko Call Karne Ke Liye Istemal Karte Hai | Waise Hi Us Class Ko Function Ke Rup Mai Variable Par Store Karte Hai |

Syntax :

Object_Name = Class_Name()

Example

car_name = Car()   #object 

print(car_name.x)

Aap Upper Diye Gaye Code Ko Dekh Sakte Hai Hamne Ek Class Car Ke Object car_name Ko Create Kar Liya Hai Or Fir Hamne us car_name Object Ko Print Kar Diya Hai Joki Uska Output Niche Dikhaya Gaya Hai |

Output:

ALTO

Python __init__() Function In Hindi

Jab Class Mai __init__() Function Define Kiya Jata Hai Or Us Class Ka Object Banaya Jata Hai Tab Ye Function Automatically Call Ho Jata Hai | __init__() Function Ko Alag Se Call Karne Ki Jarurat Nhi Hoti Hai |

Example:

Ham Ek Class Create Kar Rahe Hai Us Class Ka Name Hai Car Or Usme Hamne Model Or Name Define Kiya Hai Init Function Se |

class Car:
  def __init__(self, name, model):    #__init__() Method
    self.name = name
    self.model = model

p1 = Car("ALTO", "Alto 800 STD")    # create object

print(p1.name)
print(p1.model)

Output:

ALTO
Alto 800 STD

Dosto mujhe ummed hai ki aap Python Classes and Objects In Hindi ko acchi tarah se samanj gye honge agar aap ko ye post acchi lage to mere is website ko jarur follow kre or ha agar aap video bhi dekhna chahte hai to aap mere channel ko bhi subscribe kar sakte hai. channel ka link aapko home page par mil jayega |

Leave a Reply

Your email address will not be published. Required fields are marked *