Python variable (VARIAB)

Source: Internet
Author: User

Assign values to a variable: for example, A=1. When assigning a value to a variable, the variable is created to store the value in memory, which means that the variable is created in the memory space (corresponding to one address: one value)

Python is a dynamic type of language that can bind different types of values in the execution of a variable assignment, depending on the assigned value, which is the object's data type. It can be said that in Python the object has a data type variable with no data type.

The process of assigning a variable value:

>>> A = 1

1. Open a position in memory to represent the 1 object.

2. Create a variable A, if he has not been assigned a value before, a and object 1 link, if he was created and assigned before he will disconnect the previous object and break the existing link and create a new link with 1. (After running a=1, variable A becomes a reference of 1)

Variable Naming conventions:

Syntax: (underscore or letter) + (any number of letters, numbers, or underscores)

The variable name must begin with an underscore or letter, followed by any number of letters, numbers, or underscores.

Case-sensitive: Dream and Dream are different

Prohibit use of reserved words

  

Python allows you to assign values to multiple variables at the same time. For example:

A = b = c = 1

The above example creates an integer object with a value of 1 and three variables allocated to the same memory space.

You can also specify multiple variables for multiple objects. For example:

A, b, C = 1, 2, "John"

For the above example, two integer objects 1 and 2 are assigned to variables A and B, and the string object "John" is assigned to variable C.



Python variable (VARIAB)

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.