Python | Operator | Identity & Membership Operators By. Shivansh Sir

 PYTHON PROGRAMMING

PYTHON | IDENTITY OPERATOR

1. is :- जब एक जैसे Object का वर्णन किया जाता है तो True return करता है |

2. is not :- जब अलग-अलग Object का वर्णन किया जाता है तो True return करता है |

'is' Identity Operator

Source Code

a = 4

b = 5

c = 4

print(a is c)

print((a<b) is (b>a))

Output

True

True

'is not' Identity Operator

Source Code

a = 4

b = 5

print(a is not b)

Output

True

PYTHON | MEMBERSHIP OPERATOR

1. in :- अगर Collection (list, tuple, dictionary, string, set) में element या value मिली तो True return करता है |

2. not in :- अगर Collection(list, tuple, dictionary, string, set) में element या value नहीं मिली तो True return करता है |

'in' Membership Operator

Source Code :

a = "Hello World"

print("ll" in a)

list = [1, "o", 8, 5]

print(1 in list)

Output

True

True

'not in' Membership Operator

Source Code

a = "Hello World"

print("lol" not in a)

list = [1, "o", 8, 5]

print(3 not in list)

Output

True

True


Comments

Popular posts from this blog

Python | All in One Program By. Shivansh Sir

Python | Data Types | Number & it's Conversion By. Shivansh Sir

Python | Loop | For Loop By. Shivansh Sir