Python Base---data types

Source: Internet
Author: User

Basic data types



Type(data) view data Types

ID (data) view memory address


1. Digital


A. Int ( integer number )

on the four- bit machine, the number of digits of the integer is the value range of -2**31~2**31-1, i.e. -2147483648~ 2147483647

on the system, the number of digits of the integer is 9223372036854775808, and the value range is -2**63~2**63-1. ~9223372036854775807

B.long (length integer number)

with Unlike the C language,python 's long integers do not refer to the positioning width, that is, Python does not limit the size of long integer values, but in fact, because of limited machine memory, we use a long integer value can not be infinite.

Attention:

1. since Python2.2 , if an integer overflow occurs, Python automatically converts the integer data to a long integer, so there is now no letter L after the long integer data It's not going to cause serious consequences.

2. There is no longer a long type in Python3 , all int


2. string


A. in Python , quoted characters are considered to be strings (quotation marks: single, double, and triple quotes)

B. strings can also be mathematically operated, but only by adding or multiplying, and the concatenation of strings can only be a string between the two, and cannot be spliced with numbers or other types

3, boolean value (bool)

The main use of logical judgment

There are only two values:

True ( true )

False ( false )

Practice:

Judging Boolean values

>>>true or Flase and flase

True

4. List

Can hold multiple values, each of which can correspond to any one data type

names=[' Alex ', ' Egon ', ' Lyndon '

to take the elements in the list, you need to pass the subscript, starting with 0

5. Dictionaries

Store values in a key:value way, and can hold multiple values

each value can also be any data type

but key must be an immutable data type

dic={' name ': ' Egon ', ' passwd ': 123}

The dictionary uses key to fetch value

variable data types (or non- hash data types):

The ID does not change

Type does not change

the value has changed.

Lists are mutable types, numbers and strings are immutable types


This article is from the "Lyndon" blog, make sure to keep this source http://lyndon.blog.51cto.com/11474010/1946066

Python Base---data types

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.