1. Python Variable settings

Source: Internet
Author: User

1. What is a variable

Variable as the name implies the amount of change, the amount is a way of representing a state, and can be changed

2, why to use the variable

The execution of a program is always in a state of flux, and we can use a variable to represent the state of the program in progress and record it.

3. How to use variables

Key=value

Example

A=123

Three elements of a variable:

Key ———— "a"

= ————— "Assigned value

123 ———— "Specific status (content)

A variable is defined in a way that has its fixed name:

Variable names can only be any combination of letters, numbers, or underscores

The first character of a variable name cannot be a number

Cannot conflict with Python keyword (avoid invoking problems in use)

[' and ', ' as ', ' assert ', ' Break ', ' class ', ' Continue ', ' Def ', ' del ', ' elif ', ' Else ', ' except ', ' exec ', ' finally ', ' for ', ' F ' Rom ', ' Global ', ' if ', ' import ',

' In ', ' was ', ' lambda ', ' not ', ' or ', ' pass ', ' print ', ' raise ', ' return ', ' Try ', ' when ', ' with ', ' yield ']

The significance of defining variables is that we call this variable later, so it is best to set the variable name with its special meaning, example:

Name= ' Wyf '

Age=26

salary=1000000 # #意淫的

Underline is also good, can be relatively clear expression of a relatively long variable:

student_of_middle=300 #中学生300人

                                            

1. Python Variable settings

Related Article

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.