Go: Python operator learning

Source: Internet
Author: User

Python's operators are mostly the same as Java, similar in function, with the same level of operators, this blog will learn the python operator:

python and Java operators
Python Java Describe
Or || Logical OR
and && Logic and
Not Logical Non-
<,>,<=,>=,==,!= or <> <,>,<=,>=,==,!= Compare operations
Is,is not instanceof Identity verification
| | Bit or
& & Bit and
^ ^ Bit XOR or
<<,>> <<,>> Shift
+,-,*,/ +,-,*,/ Subtraction
% % Remainder
~ ~ Bit take-fill

It is important to note that in Python and Java, some operators are overloaded, like "+", "%", and so on. As for the operational level, Python and Java almost, in fact, do not remember, with parentheses Bai, hehe, programmers are always very "lazy."

Here is an example

>>> A = 3    >>> b = 4    >>> B/2 + a    5    >>> b/(2.0 + a)    0.80000000000000 004    >>> B << 2    >>> A | 2    3    >>> A & 1    1    >> > A/2    1    >>> a 2    1    >>> B > A    true >>> not   True   False   >>> (5 + 4j) * (7-2j)    (43+18j)    >>> 2 is 3    False   >>> 2 was not 3
   true   >>> 2 is 2    True   >>>    

  

Go: Python operator learning

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.