Basic Python 16: Python Operators Special operators

Published: 23 September 2022
on channel: Testing Tutorialspoint
23
4

Python Operators - Special operators:
-------------------------------------
Python language offers some special types of operators like the identity operator or the membership operator.

Identity operators:

is and is not are the identity operators in Python. They are used to check if two values (or variables) are located on the same part of the memory. Two variables that are equal does not imply that they are identical.

is True if the operands are identical (refer to the same object) x is True
is not True if the operands are not identical (do not refer to the same object) x is not True
ex;
x1 = 5
y1 = 5
x2 = 'Hello'
y2 = 'Hello'
x3 = [1,2,3]
y3 = [1,2,3]

Output: False
print(x1 is not y1)

Output: True
print(x2 is y2)

Output: False
print(x3 is y3)

Membership operators:

in and not in are the membership operators in Python. They are used to test whether a value or variable is found in a sequence (string, list, tuple, set and dictionary).
ex:
in True if value/variable is found in the sequence 5 in x
not in True if value/variable is not found in the sequence 5 not in x

x = 'Hello world'
y = {1:'a',2:'b'}

Output: True
print('H' in x)

Output: True
print('hello' not in x)

Output: True
print(1 in y)

Output: False
print('a' in y)
__________________ API Automation _________________
➡️ Rest Assured Using Java →    • Rest Assured  
➡️ Karate Framework using Maven →    • Karate Framework Using Maven Project  
_____________ Programing Language ____________________
➡️ Basic Python →    • Basic Python  
➡️ Core Java →    • CoreJava  
___________ Performances Testing ___________________
➡️ JMeter Beginner →    • JMeter Beginner  
➡️ Locust Beginner →    • Locust  
___________ Git and GitHub _____________________________
➡️ Git and GitHub Beginner →    • Git and GitHub Beginner  

_____________Manual Testing ____________________
➡️ Manual Testing →    • Manual Testing  

______________Automation Testing __________________
➡️ Selenium Cucumber Framework using Java →    • Selenium Cucumber BDD Framework with ...  
➡️ Robot Framework with Python →    • Python With Robot Framework  
➡️ Beginner Karate Framework using Intellij →    • Karate Framework Beginner  
➡️ Karate Framework with Gradle using eclipse →    • Karate Framework using Gradle Project  
➡️ Basic Selenium WebDriver using Java →    • Selenium WebDriver  
➡️ TestNG Framework →    • TestNG Framework  
➡️ Robot Framework with RIDE →    • RIDE With Robot Framework  
________________ Beginner Jenkins ____________________
➡️ Beginner Jenkins →    • Beginner Jenkins  


Watch video Basic Python 16: Python Operators Special operators online, duration hours minute second in high quality that is uploaded to the channel Testing Tutorialspoint 23 September 2022. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 23 times and liked it 4 visitors.