Python Basic Learning Notes (vii)--common operators

Source: Internet
Author: User

Python commonly used operators are: arithmetic operators, logical operators, comparison operators, respectively, described below.


1. Arithmetic operator

+ addition operator

-Subtraction operator

* Multiplication operator

/Division operator (Precise operation)

Division operator (the result is an integer that ignores the fractional part of the calculation result)

* * Power operator, or exponentiation operation

% modulo operator, which is the remainder


2. Comparison operators

> Greater than

>= greater than or equal to

< less than

<= less than or equal to

= = equals

! = does not equal


3. Logical operators

Not means to negate

and Logic and

or logical OR


4. Precedence of various operators

1) Overall: The arithmetic operator is higher than the comparison operator, and the comparison operator is higher than the logical operator.

2) Specific,

Arithmetic operators: Follow the mathematical law, single-specific to the power operator is special, the power operator * * Priority is higher than the left of the monocular operator (such as-minus), lower than the right of the monocular operator (such as-number)

Logical operators: Priority once from high to low for not > and > or

There is a picture of the truth:

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/88/5D/wKiom1fyRIPw4m1yAAQSx_7ysXQ751.png-wh_500x0-wm_3 -wmp_4-s_2444524886.png "title=" Prioroty.png "alt=" Wkiom1fyripw4m1yaaqsx_7ysxq751.png-wh_50 "/>



This article is from the "Davidlee's Linux Road" blog, so be sure to keep this source http://davidlinux.blog.51cto.com/5965954/1858612

Python Basic Learning Notes (vii)--common operators

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.