Python and And OR

Source: Internet
Author: User

>>> 1 and 2 and 33>>> False and 1 and 2false>>> 1 and 2 and 3 and 44>>> 1 and 2 and 3 and falsefalse>>> 1 or 2 or 31>>> false or 1 or 21>>> 1 and 2 and 3 or FALSE and 13

Boolean operations are performed in Python and and OR, but the actual value is returned.

1. All and, if true, returns the last variable value, or False to return the first false value

2. All or, returns the last value if both are false, and if true, returns the first truth

3.and and OR:

>>> 1 and 2 or false2>>> False and 1 or 22

(A and B) or C: If A and B are true then the result is B, if A and B is false, the result is C, in fact, the same principle as and and or, similar to C to bool? A:b

Also: and priority is higher than or

>>>false and 1 or 22>>> 1 or 2 and false1>>> (1 or 2) and Falsefalse

From the above 3 examples, the first one to determine the priority of or is not and high, the following 2 examples can be known and and or priority cannot be the same, if the same, the 2nd example of the result is false?

Python and And OR

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.