In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you the python logic operation and strange return value (not,and,or) problem example analysis, I believe that most people do not know much, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
First, the priority for and, or, and not is not > and > or.
The same priority is calculated from left to right.
Let's start with non-operations. Python's non-operations are nothing special compared to these languages. Not has only two return values, True and False. In Python, objects with false truth values, including False,None, the number 0, an empty string, and an empty container type. Any object other than that is true.
Then there is the and operation. The rules for the and (and) operation of Python are
If the expression on the left is true, the value of the expression on the right is returned
Otherwise, return the value of the expression on the left
Finally, the rules for Python OR (or) operations are
If the expression on the left is true, the value of the expression on the left is returned
Otherwise, return the value of the expression on the right
Feel it in code:
So now let's add priority-related hybrid operations:
# first of all, not has the highest priority, then not 8 returns False
# (False or 3 and 4 or 2 and 0 or 9 and 7)
# the next priority is and
# (False or 4 or 0 or)
# finally or returns a true value of 4
The above is all the contents of the article "example Analysis of python Logic Operations and Strange return value (not,and,or) problems". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.