Python Basic Data classification method

Source: Internet
Author: User
Tags scalar

First, the memory model

Classification of variables based on their organization in memory

The type of Python, like most other languages, can hold one or more values. A type that can hold a single literal object we call it atomic or scalar storage , those types that can hold multiple objects, which we call container storage . (Container objects are sometimes referred to as compound objects in a document, but they do not just refer to types, but also include objects such as class instances)

Storage Model


category     

Python Type
Scalar/Atomic Type Numeric (all numeric type) strings (all text)
Container Type Lists, tuples, dictionaries


Second, the Access model

Classify data types according to how you access the data that we store. There are three ways to access the model: direct access, order, and mapping .

               Pyth On data type                   Access model
                        Digital
              & nbsp   Direct access to
            strings, lists, tuples                   sequential access
                        Dictionary                   map access


Third, update the model

Some types allow their values to be updated, while others are not allowed. (value is changed)

Data Type Storage Model Update Model Access Model
Digital
Scalar Cannot be changed Direct access
String
Scalar Cannot be changed Sequential access
List Container Can be changed Sequential access
Meta-group Container Cannot be changed Sequential access
Dictionary Container Can be changed Map Access


Add:

A dictionary is an unordered storage structure that includes a keyword (key) and a value that corresponds to a keyword (value). The format of the dictionary is: dictionary = {Key:value}. A keyword is an immutable type , such as a string, an integer, a tuple that contains only immutable objects, and a list that cannot be used as a keyword. If there is a keyword pair in the list, you can construct the dictionary directly with Dict ().

The only difference between set and dict is that it does not store the corresponding value, but the set principle is the same as the dict, so it is also not possible to put mutable objects, because it is not possible to determine whether the two Mutable objects are equal, and there is no guarantee that there will be no duplicate elements inside the set. Try putting the list in set to see if it will give an error.


Benbow in the dictionary (dict) and set (set) is somewhat ambiguous, if you read the blog has suggestions or ideas, you can discuss together.

qq:2406235544

This article is from the "Operations Diary" blog, make sure to keep this source http://gyyblog.blog.51cto.com/8666992/1924039

Python Basic Data classification method

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.