Explaining the identity operators in Python

Source: Internet
Author: User
The following table lists the identity operators supported by all Python languages.

Example:

Try the following example to understand the identity operators provided by all Python programming languages:

#!/usr/bin/pythona = 20b = 20if (A is b):  print "line 1-a and B has same identity" else:  print "line 1-a and  b does not have same identity "if (ID (a) = = ID (b)):  print" line 2-a and B has same identity "else:  print" Line 2 -A and B do not have the same identity "B = 30if (A is b):  print" line 3-a and B has same identity "else:  print" Line 3-a and B does not have the same identity "if (A is not B): The print" line 4-a and B does not have  same identity "else:< C7/>print "line 4-a and B has same identity"

When executing the above program it produces the following result:

Line 1-a and B has same identityline 2-a and B has same identityline 3-a and b do not have same identityline 4-a and b do not have same identity
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.