Skip to main content

Posts

Showing posts with the label Python Oparators

Python Identity Operators

  Python Identity Operators. Operators Description Example Is Returns True If Both Same A Is B Is Not Return True If Both Are Not Same A Is Not B Ex. X = 22 Y = 25 print(X is Y) print(X == Y) print(X is not Y) print(X != Y) OUTPUT False False True True

Membership operators in Python

  x = "Saransh" print('S'in x) OUTPUT TRUE x = "Saransh" print('v'in x) OUTPUT FALSE # sentences case (h ,H) x = "Saransh" print('H'in x) output False x = "xpple" if "A" in x: print("yes a is found") else: print("No,not found") OutPut: No,not found   x = "Apple" if "A" in x: print("yes a is found") else: print("No,not found") OutPut yes a is found