Python Learning Note (i): basics

Source: Internet
Author: User

1. Exit Python with exit ()

2. The statement beginning with # is a comment

3, the PY uses the indentation format

Code indentation refers to the hierarchical relationship between each line of code by typing a space or tab in front of each line of code. Any programming language requires the structure of the Code indentation specification, and the programming style that uses the code indentation facilitates the reading and comprehension of the code. For C, C + +, Java and other languages, code indentation is just a good habit of programming and deferred. For Python, code indentation is a syntax that does not use curly braces or begin...end in the Python language ... Separating blocks of code, instead using colons and code indentation to differentiate between code levels.

If the program does not take the style of code indentation, it throws a Indentationerror exception

It is best to indent with 4 spaces when indenting (this is not mandatory, it is the contract idiomatic)

4, Case sensitive

5, add a space on each side of the assignment operator, is a good writing habit

6. Python identifiers

A python identifier is a name used to identify a variable, function, class, module, or other object. Identifiers are followed by letters A through Z or a?z with 0 or more letter underscores (_), underscores, and numbers (0?9).

Python does not allow punctuation character identifiers, such as @,$ and%

7. Reserved words

The following list shows the reserved words in Python. These reserved words cannot be used as constants or variables or any other identifier names.

and Exec Not Assert Finally
Or Break For Pass Class
From Print Continue Global Raise
Def Import Try Elif Inch
While Else Is With Except
Lambda Yield If Return Del

8, multi-line statements

Usually a line is put in one statement, but a continuation character (\) is allowed. The line continuation character cannot be used in the statement [], {}, or (), as follows:

Total = a1 +         +         a3

9, semicolon (;) allows multiple statements to be written on a single line

Python Learning Note (i): basics

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.