Small knowledge points in Python

Source: Internet
Author: User

Here is a collection of small knowledge points, for the convenience of later search.

Line and indent:

Physical line: The number of lines of code actually seen.

Logical line: function in meaning (that is, the number of rows performed by the interpreter)

If a physical row contains more than one logical row, each logical line needs to be separated by a semicolon ";" , and the last logical line can omit the semicolon

A logical line is divided into multiple physical lines using the escape character "\" to make a connection between each physical row

Indent: white space at the beginning of a logical line, usually without leaving a blank at the beginning

Indent for if and while statements: one tab character under conditions

Operator:

: Division, rounding down

%: Take the remainder

&: Bitwise AND operation in binary

|: Bitwise OR

^: Bitwise XOR (different 1, same as 0)

~: Bitwise rollover ~x=-(X+1)

<<: Binary left shift, left n units equal to multiplied by 2^n

>>: Binary right SHIFT, right shift n units equal to divided by 2^n

Operator Precedence:

      1. function invocation, addressing, subscript
      2. Power Operation * *
      3. Rollover operations
      4. PLUS sign
      5. *  /   %
      6. +   -
      7. << >>
      8. & ^ |
      9. Comparison operators:> < >= <=
      10. Logical NOT and OR
      11. Lambda expression

The difference between the expression and print execution: the expression enters a single-line command on the command line, such as: >>>a= "Hello" >>>a will have ' hello ' and if print (a), it is hello, without quotation marks.

Small knowledge points in Python

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.