On the variable and immutable types of Python

Source: Internet
Author: User

a=10;
B=a;
b=15;
Print (ID (a))
Print (ID (b))

The computer allocates a memory space to the 10 object. Its memory address is 1766916848.

Then a this variable points to the memory address.

Because of B=a, B also points to this memory address.

b=15; the computer also assigns a memory address to the 15 object, and B points to the 15 memory address.

1766916848 The value inside this memory address will not be changed. If there is not a variable pointing to the memory address, then the memory address will be freed.

Similarly, the string is the same.

Tuples are also immutable types.

While the mutable type "list, dictionary"

The list is manipulated by an index.

The value of the list index can be changed, and the dictionary is calculated by key, value, and his value can be changed.

On the variable and immutable types of Python

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.