Oldboy-homework-week1

Source: Internet
Author: User
Tags arithmetic logical operators string format

Some memories from the first week of Python's full stack development (will be added in succession)

First, some simple commands, concepts

1.print (""): Output

2. Variables

3.input (): Input

4.while loops, if, else statements

5. Data types, data operations (arithmetic operations, comparison operations, assignment operations, logic operations, etc.)

6. List, tuple (tuple)

7. String format output

8. Notes

Second, detailed review

1.print Output Example:

2. Variables:

2.1 Definition: In layman's words, it is to store some temporary data.

2.2 Variable naming rules:

① Do not use Chinese (although feasible)

② naming has a real meaning, that is, do not look at variables, only see the variable name to know what is the use of

③ cannot contain special symbols

The ④ variable name must begin with an underscore and a letter, and cannot begin with a Shuzi number, but a number can be used in the variable name

⑤ is strictly case-sensitive, that is, name and name are a different variable

⑥ avoid the system keyword, do not spoil the keyword content, or the consequences are difficult to eat

⑦ Hump Type

3.input Input:

4. Cycle

While loop example:

While nested loops example:

If_else, elif Example:

Break: Terminates the Loop

Continue: Terminating this cycle

5. Data type, data operation

1.1 Data types

①int shaping: That is, an integer

②float floating Point type: number of decimal points

1.2 Data operations

① arithmetic operations: + 、-、 *,/,//(floor except), * * (Power),% (remainder)

② comparison operations: = =,! =, >, <, >=, <=

③ Assignment operators: =, + =,-=, *=,/=,%=, **=,//=

④ logical operators: And, OR, not: follow short-circuit arithmetic between the three

⑤ member operator: In, not in example:

⑥ identity operator: IS, is not example:

⑦ bitwise operator:& (with), | (or), ^ (XOR), ~ (reverse), >> (Shift right), << (shift left)

With: Both sides of the truth is true

Or: One side is true, that is true

XOR: As long as the two sides are different, true

Inverse: True inversion is false, and vice versa

⑧ the operation precedence of these operators (truncated from Alex Li's blog, Understanding not deep, need to be understood): top to bottom priority reduction, horizontal sibling

Oldboy-homework-week1

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.