0 basic python-5.2 expression operators

Source: Internet
Author: User

An expression is the most basic tool for working with numbers

a=1# constant a=a+1# expression

Operator

Operator Describe
Yield Generator function Send protocol
Lambda args:expression Generating anonymous functions
X if y else Z Three-dimensional expression
X or Y Logical OR (existence of short-circuit algorithm)
X and y Logic and (existence of short-circuit algorithm)
Not X Logical Non-
X in Y, x not in Y Member relationships
X is y, X was not y Object Entity Testing
X<y,x<=y,x>y,x>=y,x==y,x!=y Compare size
X|y Bit or, set merge set
X^y Bit XOR, set symmetry difference
X&y Bit and, set intersection
X<<y,x>>y Move left or right y position
X+y,x-y Add and subtract, merge delete
x*y,x%y,x/y,x//y Multiply, take the remainder, except, the floor
-x,+x One-dollar subtraction
~x bitwise complement (negation)
X**y Power operation
X[i] Index, Function call
X[I:J:K] Sharding
X (...) Calling functions
X.attr Call Properties
() Tuples, expressions, generators
[] List, list resolution
{} Dictionary, Collection, collection, and dictionary parsing

3. Priority level

The table above is sorted by priority, the higher the precedence, the same as the priority of the same row


4. If there is a parenthesis in the expression, the parentheses take precedence

(1+2) *31+2*3

5. When the type is mixed, the type is automatically upgraded

Sort from numeric complexity: shaping, floating point, plural

So if the shaping is combined with a floating-point type, the result is a floating-point type




Right here, thank you.

------------------------------------------------------------------

Click to jump 0 basic python-Catalogue



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

0 basic python-5.2 expression operators

Related Article

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.