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