Python Learning (2) variables, constants, annotations

Source: Internet
Author: User

1. Variables

The concept of variables: variables are meant to store some intermediate results in the process of program operation, in order to facilitate later invocation

Naming rules for variables:

1. To have descriptive
2. Variable name can only _, number, letter composition, can not be a space or special characters (#?<.,¥$*!~)
3. Cannot use Chinese as variable name
4. Cannot start with a number
5. Reserved characters cannot be used

X=1y=2z=x*yprint("x multiplied by y equals:", Z)

Output Result:

x multiplied by y equals: 2

2. Constants

The concept of constants: The unchanging amount of pie = 3.141592653 ....

All variables in Python are mutable, so the variable names are all capitalized to represent the secondary variables as constants.

3. Comments

Single-line comment with #
Multiline comment with three single quotes or three double quotation marks ' ' annotated content '

# Use the # single-line comment, Python single-line comment " " Single quote multi-line comment, Python multiline comment single quote multiline comment, Python multiline comment single quote multiline comment, Python multiline comment " " """ double quotes multi-line comment, Python multiline comment Double quote multiline comment, Python multiline comment Double quote multiline comment, Python multiline comment """

Python Learning (2) variables, constants, annotations

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.