Python Identity Operators || identity operators in python, identity operators in python in hindi

Home 👉 O level 👉 Python 👉 Unit 4


 Identity Operators in Python

ये ऑपरेटर्स ऑब्जेक्ट्स की आइडेंटिटी (मेमोरी एड्रेस) को चेक करते हैं और समान होने या न होने के आधार पर True या False में परिणाम देते हैं। पायथन में, आइडेंटिटी ऑपरेटरों का उपयोग यह निर्धारित करने के लिए किया जाता है कि क्या दो वेरिएबल या ऑब्जेक्ट एक ही मेमोरी स्थान को संदर्भित (दर्शाते) करते हैं या एक ही पहचान रखते हैं। 

आइडेंटिटी ऑपरेटरों का उपयोग अक्सर ऑब्जेक्ट की तुलना करने और यह जांचने के लिए किया जाता है कि क्या वे एक ही उदाहरण हैं, खासकर जब लिस्ट, डिक्शनरी और यूजर-डिफाइंड क्लासेज जैसी परिवर्तनशील ऑब्जेक्ट से निपटते हैं। ध्यान रखें कि ये ऑपरेटर पहचान की जाँच करते हैं, समानता की नहीं। दो ऑब्जेक्ट मूल्य में समान हो सकती हैं लेकिन उनकी पहचान समान नहीं हो सकती।

These operators check the identity (memory address) of the objects and return True or False depending on whether they are equal or not. In Python, identity operators are used to determine if two variables or objects reference the same memory location or have the same identity. 

Identity operators are often used to compare objects and check if they are the same instance, especially when dealing with mutable objects like lists, dictionaries, and user-defined classes. Keep in mind that these operators check for identity, not equality. Two objects can be equal in value but not have the same identity.

  • Is Identitical ( is )

  • Is Not Identitical ( is not )

Is Identical (is):-

    ये ऑपरेटर दो ऑब्जेक्ट के identity यानि object reference (मेमोरी एड्रेस) के समान होने पर True देता है अन्यथा False देता है। पायथन में, "is" ऑपरेटर का उपयोग यह परीक्षण करने के लिए किया जाता है कि क्या दो वेरिएबल या ऑब्जेक्ट एक ही मेमोरी स्थान या मेमोरी में एक ही ऑब्जेक्ट को संदर्भित (दर्शाते) करते हैं। यह ऑब्जेक्ट की पहचान की जाँच करता है, न कि केवल मूल्यों की समानता की। 

    जब आप "is" ऑपरेटर का उपयोग करते हैं, तो यह जाँचता है कि क्या दो वेरिएबल मेमोरी में एक ही ऑब्जेक्ट को संदर्भित करते हैं। यदि वे ऐसा करते हैं, तो यह 'True' लौटाता है; अन्यथा, यह 'False' लौटाता है। "is" ऑपरेटर के विपरीत, आप "==" ऑपरेटर का उपयोग यह जांचने के लिए कर सकते हैं कि क्या दो वेरिएबल के समान मान हैं, भले ही वे मेमोरी में एक ही ऑब्जेक्ट को संदर्भित करते हों।

आप आमतौर पर निम्नलिखित स्थितियों में `is` ऑपरेटर का उपयोग करते हैं:

  • None से तुलना:
  • ऑब्जेक्ट्स की तुलना करना:
  • विशिष्ट कांस्टेंट की जाँच करना:

This operator returns True if the identity of two objects i.e. object reference (memory address) is same, otherwise it returns False. In Python, the "is" operator is used to test whether two variables or objects reference the same memory location or the same object in memory. It checks for object identity, not just equality of values. 

When you use the "is" operator, it checks if two variables reference the same object in memory. If they do, it returns `True`; otherwise, it returns `False`. In contrast to the "is" operator, you can use the "==" operator to test whether two variables have the same values, regardless of whether they reference the same object in memory.

You typically use the `is` operator in the following situations:

  • Comparing None:
  • Comparing Objects:
  • Checking for Specific Constants:


syntax: x is y
example:
a=1
b=1
a is b
result: True

Is Not Identical (is not):-

    ये ऑपरेटर दो ऑब्जेक्ट के identity यानि object reference (मेमोरी एड्रेस) के समान  होने पर True देता है अन्यथा False देता है। पायथन में, 'is not' ऑपरेटर एक तुलना ऑपरेटर है जिसका उपयोग यह जांचने के लिए किया जाता है कि क्या दो वेरिएबल या ऑब्जेक्ट एक ही मेमोरी स्थान को संदर्भित नहीं करते हैं। यह `is` ऑपरेटर का निषेध है। `x is not y` लौटाता है `True` यदि `x` और `y` मेमोरी में एक ही ऑब्जेक्ट को संदर्भित नहीं करते हैं, और यदि वे एक ही ऑब्जेक्ट को संदर्भित करते हैं तो `False` देता है।

    This operator returns True if the identity of two objects i.e. object reference (memory address) is not the same, otherwise it returns False. In Python, the `is not` operator is a comparison operator used to check if two variables or objects do not refer to the same memory location. It is the negation of the `is` operator. `x is not y` returns `True` if `x` and `y` do not reference the same object in memory, and `False` if they do reference the same object.


syntax: x is not y
example:
a=1
b=2
a is not b
result: True




---END---

Comments