And,or,not the basic syntax of Python

Source: Internet
Author: User

The priority of ' and ', ' or ' and ' not ' is not>and>or

First, the priority of ' and ', ' or ' and ' not ' is not>and>or.

The result of And:x and Y returns is the value that determines the result of the expression. If x is true, Y determines the result, returns Y, and if x is False, x determines that the result is false and returns X.

Or:x or Y has a true, and the result is true.

Not: Returns the "opposite value" of the result of the expression. Returns false if the expression result is true, or true if the expression result is false.

PS: Add, when print output, print (x or y), print (x and y), there are the following rules.

Or:x is true (not 0 is true), returns X otherwise returns Y.

Print (2 or 3)//2

Print (0 or 100)//100

And:x is true (not 0 is true), then Y is returned, otherwise X is returned.

Print (3 and 100)//100

Print (0 and 2)//0

And,or,not the basic syntax of Python

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.