Python Learning Note (vi) operator

Source: Internet
Author: User

Arithmetic operators in Python:

+-*/% *//

Attention:

/: For real division, which corresponds to the division in mathematics, usually returns a floating-point number

: Take the divisible method, namely the pick-up

%: modulo, which takes the remainder

* *: Power operation, one thing to note here is that the power operator precedence is higher than the single-mesh operator on its left, and has a lower precedence than the single-operator on its right.

1 >>> 10/22 5.03 >>>//24 55 >>> 10/36 3.33333333333333357 >>>//38 39 >>> 3Ten 1 One >>>-2 * * 3 A -8 - >>> 2 * *-3 -0.125
View Code

Logical operators:

and (with) or (or) not (non)

1 >>> 1 > 2 or 4 > 3 2 True 3 < and 5 < 44False5><  2  6True
View Code

Priority level:

    • Power Operation * *
    • PLUS sign +-
    • Arithmetic operator *///
    • + -
    • Compare operators < <= > >= = = = =
    • Logical operator not > and > or

From top to bottom, the priority gradually decreases.

  

Python Learning Note (vi) operator

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.