Python Membership Operators || membership operators in python, membership operators in python in hindi

Home ๐Ÿ‘‰ O level ๐Ÿ‘‰ Python ๐Ÿ‘‰ Unit 4


Membership Operators in Python

เคฏे เค‘เคชเคฐेเคŸเคฐ्เคธ เค•िเคธी เคฎाเคจ เค•ो เค•िเคธी เคฆिเค เค—เค เคฎाเคจों เค•े เคธเคฎूเคน เคœैเคธे string, list เค†เคฆि เคฎें เค‰เคธ เคฎाเคจ เค•ो เค–ोเคœเคคे เคนैं เค”เคฐ เคฎाเคจ เค•े เคฎिเคฒเคจे เคฏा เคจ เคฎिเคฒเคจे เคชเคฐ True เคฏा False เคฎें เคชเคฐिเคฃाเคฎ เคฆेเคคे เคนैं। เคชाเคฏเคฅเคจ เคฎें เคฎेเคฎ्เคฌเคฐเคถिเคช เค‘เคชเคฐेเคŸเคฐों เค•ा เค‰เคชเคฏोเค— เคฏเคน เคชเคฐीเค•्เคทเคฃ เค•เคฐเคจे เค•े เคฒिเค เค•िเคฏा เคœाเคคा เคนै เค•ि เค•ोเคˆ เคฎाเคจ เคฏा เคเคฒिเคฎेंเคŸ เค•िเคธी เค—्เคฐुเคช (เคธीเค•्เคตेंเคธ) เค•ा เคธเคฆเคธ्เคฏ เคนै, เคœैเคธे เคธ्เคŸ्เคฐिंเค—, เคธूเคšी เคฏा เคŸเคชเคฒ। 

เคฎेเคฎ्เคฌเคฐเคถिเคช เค‘เคชเคฐेเคŸเคฐों เค•ा เค‰เคชเคฏोเค— เค…เค•्เคธเคฐ เคธเคถเคฐ्เคค เคฌเคฏाเคจों เค”เคฐ เคฒूเคชों เคฎें เค•िเคฏा เคœाเคคा เคนै เคคाเค•ि เคฏเคน เคœांเคšा เคœा เคธเค•े เค•ि เค•ोเคˆ เคเคฒिเคฎेंเคŸ เค‰เคธ เคธ्เคฅिเคคि เค•े เค†เคงाเคฐ เคชเคฐ เคตिเคถिเคท्เคŸ เค•ाเคฐ्เคฐเคตाเคˆ เค•เคฐเคจे เคธे เคชเคนเคฒे เค—्เคฐुเคช (เคธीเค•्เคตेंเคธ) เคฎें เคฎौเคœूเคฆ เคนै เคฏा เคจเคนीं।

These operators find a value in a given set of values like string, list etc. and return the result True or False if the value is found or not found. Membership operators in Python are used to test whether a value or element is a member of a sequence, such as a string, list, or tuple. 

Membership operators are often used in conditional statements and loops to check if an element is present in a collection before taking specific actions based on that condition.

  • In Membership ( in )

  • Not In Membership ( not in )

In Membership (in):-

    เคฏे เค‘เคชเคฐेเคŸเคฐ เค•िเคธी เคฎाเคจ เค•े เค•िเคธी เคฆिเค เค—เค เคฎाเคจों เค•े เคธเคฎूเคน เคฎें เคนोเคจे เค•ा เคชเคคा เค•เคฐเคคे เคนैं เคคเคฅा เคฎाเคจ เค•े เคฎिเคฒเคจे เคชเคฐ True  เคฆेเคคे เคนैं เค…เคจ्เคฏเคฅा False  เคฆेเคคे เคนैं। เคชाเคฏเคฅเคจ เคฎें "in" เค‘เคชเคฐेเคŸเคฐ เค•ा เค‰เคชเคฏोเค— เคฏเคน เคœांเคšเคจे เค•े เคฒिเค เค•िเคฏा เคœाเคคा เคนै เค•ि เค•्เคฏा เค•ोเคˆ เคฎाเคจ เค•िเคธी เคธीเค•्เคตेंเคธ (เคœैเคธे เคธ्เคŸ्เคฐिंเค—, เคธूเคšी, เคŸเคชเคฒ เคฏा เคถเคฌ्เคฆเค•ोเคถ) เค•े เคญीเคคเคฐ เคฎौเคœूเคฆ เคนै। เคฏเคน เคเค• เคฌूเคฒिเคฏเคจ เคฎाเคจ เคฒौเคŸाเคคा เคนै, True เคฏा False, เคฏเคน เคฆเคฐ्เคถाเคคा เคนै เค•ि เคจिเคฐ्เคฆिเคท्เคŸ เคฎाเคจ เค…เคจुเค•्เคฐเคฎ เคฎें เคฎौเคœूเคฆ เคนै เคฏा เคจเคนीं। "in" เค‘เคชเคฐेเคŸเคฐ เค•ा เค‰เคชเคฏोเค— เค†เคฎเคคौเคฐ เคชเคฐ เคธเคถเคฐ्เคค เคฌเคฏाเคจों เคฎें เคฏเคน เคœांเคšเคจे เค•े เคฒिเค เค•िเคฏा เคœाเคคा เคนै เค•ि เค•ुเค› เค•ाเคฐ्เคฐเคตाเคˆ เค•เคฐเคจे เคธे เคชเคนเคฒे เคกेเคŸा เคธंเคฐเคšเคจा เคฎें เค•ोเคˆ เคตिเคถेเคท เคฎाเคจ เคฎौเคœूเคฆ เคนै เคฏा เคจเคนीं।

เคฏเคนां เคฌเคคाเคฏा เค—เคฏा เคนै เค•ि เค†เคช 'เค‡เคจ' เค‘เคชเคฐेเคŸเคฐ เค•ा เค‰เคชเคฏोเค— เค•ैเคธे เค•เคฐ เคธเค•เคคे เคนैं:

  • 1. เคœाँเคš เค•เคฐเคจा เค•ि เค•ोเคˆ เคเคฒिเคฎेंเคŸ เคธ्เคŸ्เคฐिंเค— เคฎें เคนै เคฏा เคจเคนीं:
  • 2. เคœाँเคš เค•เคฐเคจा เค•ि เค•ोเคˆ เคเคฒिเคฎेंเคŸ เคธूเคšी เคฎें เคนै เคฏा เคจเคนीं:
  • 3. เคœाँเคš เค•เคฐเคจा เค•ि เค•ोเคˆ เค•ुंเคœी เคกिเค•्เคถเคจเคฐी เคฎें เคนै เคฏा เคจเคนीं:

'เค‡เคจ' เค‘เคชเคฐेเคŸเคฐ เคตिเคญिเคจ्เคจ เค•ाเคฐ्เคฏों เค•े เคฒिเค เค‰เคชเคฏोเค—ी เคนै, เคœैเคธे เคธंเค—्เคฐเคน เค•े เคญीเคคเคฐ เคตिเคถिเคท्เคŸ เคกेเคŸा เค•ी เค–ोเคœ เค•เคฐเคจा, เคเคฒिเคฎेंเคŸ เคชเคฐ เคชुเคจเคฐाเคตृเคค्เคคि เค•เคฐเคจा, เคฏा เคกिเค•्เคถเคจเคฐी เคฎें เค•ुंเคœिเคฏों เค•े เค…เคธ्เคคिเคค्เคต เค•ी เคœांเคš เค•เคฐเคจा। เคฏเคน เคธเคถเคฐ्เคค เคœांเคš เค•ो เคธเคฐเคฒ เคฌเคจाเคคा เคนै เค”เคฐ เค†เคชเค•े เค•ोเคก เค•ो เค…เคงिเค• เคชเค เคจीเคฏ เค”เคฐ เค•ुเคถเคฒ เคฌเคจा เคธเค•เคคा เคนै।

    This operator checks whether a value is in a given set of values and returns True if the value is found, otherwise it returns False. The "in" operator in Python is used to check if a value exists within a sequence (such as a string, list, tuple, or dictionary). It returns a Boolean value, True or False, indicating whether the specified value is present in the sequence. The "in" operator is commonly used in conditional statements to test whether a particular value is present in a data structure before taking certain actions.

Here's how you can use the 'in' operator:

  • Checking if an element is in a string:
  • Checking if an element is in a list:
  • Checking if a key is in a dictionary:

The 'in' operator is useful for various tasks, such as searching for specific data within a collection, iterating over elements, or checking for the existence of keys in dictionaries. It simplifies conditional checks and can make your code more readable and efficient.


syntax: x in group
example: 2 in [1,2,3]
result: True

Not In Membership (not in):-

    เคฏे เค‘เคชเคฐेเคŸเคฐ เค•िเคธी เคฎाเคจ เค•े เค•िเคธी เคฆिเค เค—เค เคฎाเคจों เค•े เคธเคฎूเคน เคฎें เคจเคนी เคนोเคจे เค•ा เคชเคคा เค•เคฐเคคे เคนैं เคคเคฅा เคฎाเคจ เค•े เคจ เคนोเคจे เคชเคฐ True  เคฆेเคคे เคนैं เค…เคจ्เคฏเคฅा False  เคฆेเคคे เคนैं। เคชाเคฏเคฅเคจ เคฎें 'not in' เค‘เคชเคฐेเคŸเคฐ เค•ा เค‰เคชเคฏोเค— เคฏเคน เคœांเคšเคจे เค•े เคฒिเค เค•िเคฏा เคœाเคคा เคนै เค•ि เค•ोเคˆ เคฎाเคจ เค•िเคธी เคธीเค•्เคตेंเคธ เคฎें เคฎौเคœूเคฆ เคจเคนीं เคนै, เคœैเคธे เค•ि เคธूเคšी, เคŸुเคชเคฒ, เคธ्เคŸ्เคฐिंเค— เคฏा เคถเคฌ्เคฆเค•ोเคถ। เคฏเคฆि เคธीเค•्เคตेंเคธ เคฎें เคจिเคฐ्เคฆिเคท्เคŸ เคฎाเคจ เคจเคนीं เคฎिเคฒเคคा เคนै เคคो เคฏเคน 'True' เค”เคฐ เคฏเคฆि เคฏเคน เคชाเคฏा เคœाเคคा เคนै เคคो 'False' เคฒौเคŸाเคคा เคนै। เค†เคช เค•िเคธी เคธीเค•्เคตेंเคธ เคฎें เค•िเคธी เคตिเคถिเคท्เคŸ เคฎाเคจ เค•ी เค…เคจुเคชเคธ्เคฅिเคคि เค•ी เคœांเคš เค•เคฐเคจे เค•े เคฒिเค 'not in' เค‘เคชเคฐेเคŸเคฐ เค•ा เค‰เคชเคฏोเค— เค•เคฐ เคธเค•เคคे เคนैं, เคœो เคธเคถเคฐ्เคค เคฌเคฏाเคจों เค”เคฐ เคฒूเคช เคธे เคจिเคชเคŸเคจे เค•े เคฆौเคฐाเคจ เคชाเคฏเคฅเคจ เคฎें เคเค• เคธाเคฎाเคจ्เคฏ เค‘เคชเคฐेเคถเคจ เคนै।

เคฏเคนां เค•ुเค› เค‰เคฆाเคนเคฐเคฃ เคฆिเค เค—เค เคนैं เคœเคนां เค†เคช `not in` เค‘เคชเคฐेเคŸเคฐ เค•ा เค‰เคชเคฏोเค— เค•เคฐ เคธเค•เคคे เคนैं:

  • เคฏเคน เคœांเคšเคจा เค•ि เค•ोเคˆ เค†เค‡เคŸเคฎ เคธूเคšी เคฎें เคจเคนीं เคนै:
  • เคธเคค्เคฏाเคชिเคค เค•เคฐเคจा เค•ि เค•ोเคˆ เคตเคฐ्เคฃ เคธ्เคŸ्เคฐिंเค— เคฎें เคจเคนीं เคนै:
  • เคฏเคน เคœाँเคšเคจा เค•ि เค•ोเคˆ เค•ुंเคœी เคถเคฌ्เคฆเค•ोเคถ เคฎें เคคो เคจเคนीं เคนै:

    This operator determines whether a value is not in a given set of values and returns True if the value does not exist, otherwise it returns False. The 'not in' operator in Python is used to check if a value does not exist in a sequence, such as a list, tuple, string, or dictionary. It returns `True` if the specified value is not found in the sequence and `False` if it is found. You can use the 'not in' operator to check for the absence of a specific value in a sequence, which is a common operation in Python when dealing with conditional statements and loops.

Here are a couple of examples of where you can use the `not in` operator:

  • Checking if an item is not in a list:
  • Verifying if a character is not in a string:
  • Checking if a key is not in a dictionary:


syntax: x not in group
example: 4 not in [1,2,3]
result: True



NEXT:-

---END---

Comments