Python syntax element analysis

Source: Internet
Author: User

Indent in
1 indents = 4 spaces
used in The hierarchical relationship of the code is indicated in Python
Indentation is The only means of demonstrating the program framework in the Python language

Comments
N Note: The programmer adds the description information to the code that is not executed by the computer
N Two ways to annotate:
N Single-line comments start with #
multiple lines of comments to "' Start and end

Constants and variables
N Constants: Elements in a program where values do not change
n Benefits of using constants: For example, a program contains a constant, pi=3.14 if you use PI multiple times in a program, modify the constant definition directly when we need more precise values, without having to modify the values for each use
n variables: Elements in a program where values change or can change
N in the Python language, there is basically no difference in the use of variables and constants

Named
N naming: Associating an identifier with a program element to ensure uniqueness
n variables and constants require a name
N Naming rules:
n a combination of uppercase and lowercase letters, numbers, and underscores, but the first letter can be either uppercase or lowercase or underlined , and cannot use spaces.
n non-alphabetic symbols such as Chinese can also be used as names.
n the following are the legitimately named identifiers:
Python_is_good Python_is_not_good
_is_it_a_question_ python language

(Chinese characters can also be variable names)

Constants, variables, and names
n identifiers are case sensitive and cannot be the same as reserved words
Npython 3.x reserved word list (33)

Python syntax element analysis

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.