Python learning "5th article": Data types and Variables summary

Source: Internet
Author: User

strings, numbers, lists, tuples, dictionaries

Variable non-volatile

1. Variable: List

Such as:

>>> a = ["123", "xiaoxing"]

>>> ID (a)

4314085280

>>> a[0] = "Ceshi"

>>> ID (a)

4314085280

>>>

Here we first assign a value to the list A, get the ID (a), that is, the memory address is 4314085280

After we modify the value of the element in List A, the memory address of the re-acquisition of a is still unchanged, but the internal value has been modified, so the list is mutable.

2. Immutable: string, number, tuple

The string immutable example is as follows:

>>> name = "Xiao"

>>> ID (name)

4314237280

>>> name = "Xing"

>>> ID (name)

4314237424

>>>

Here we assign a value to the variable first Xiao, get the memory address is 4314237280, when we assign the variable again worth time, again get memory address discovery has changed, equivalent to the original created variable memory address is immutable

and cannot be modified, so the re-assignment requires a re-opening of the memory address, so it is immutable

Access Order:

1. Sequential access: strings, lists, tuples

2. Mapping: Dictionaries

Number of elements to store:

Container type: list, tuple, dictionary (represents can hold multiple values)

Atomic type: Number, string (represents can hold a value)

Python learning "5th article": Data types and Variables summary

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.