Python development "Chapter two": Python Basics-Data types

Source: Internet
Author: User

Basic data types

One, integer

such as: 18, 73, 84

Each integer has the following functions

int (integral type)

On a 32-bit machine, the number of integers is 32 bits and the value range is -2**31~2**31-1, which is -2147483648~2147483647
On a 64-bit system, the number of integers is 64 bits and the value range is -2**63~2**63-1, which is -9223372036854775808~9223372036854775807

Second, long integer type

Possible such as: 2147483649, 9223372036854775807

Each long integral type has the following functions:

Long (integer)
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.
Note that, since Python2.2, Python automatically converts integer data to long integers if an integer overflows, so it does not cause any serious consequences if you do not add the letter L after long integer data.

Third, floating-point type

such as: 3.14, 2.88

Each floating-point type has the following functions

Float (float type)
A floating-point number is used to process real numbers, which are numbers with decimals. Similar to the double type in C, accounting for 8 bytes (64 bits), where 52 bits represent the bottom, 11 bits represent the exponent, and the remaining one represents the symbol.

Four, string

such as: ' Wupeiqi ', ' Alex '

Each string has the following functions:

V. List

such as: [11,22,33], [' Wupeiqi ', ' Alex ']

Each list has the following features:

To create a list:
123 name_list =[‘alex‘, ‘seven‘, ‘eric‘]或name_list = list([‘alex‘, ‘seven‘, ‘eric‘])

Six, the tuple

such as: (11,22,33), (' Wupeiqi ', ' Alex ')

Each

To create a tuple:
#5种创建方式age = 11,22,33,44,55            #直接写数字或者字符串, the default creation type tuple string type is quoted as ' Lzl ' #输出: (one, one, one, one, and one) Age    = (11,22,33,44,55) c2/> #常见命名方式, () specifies the type tuple # output: (one, one, two, one, one) age = tuple ((11,22,33,44,55))   #tuple created (()) In a Class (()) double brackets () cannot be removed # output: (11, 2 2,,,,, () Age = tuple ([11,22,33,44,55])   #同 (()) effect is rarely used to forget it # output: (one, one, one, one, one) age = Tuple ({11,22,33,44,55}) c5/># ({}) created tuples, randomly arranged  without OVA # output: (33, 11, 44, 22, 55)

  

Tuples have the following functions:

Seven, the dictionary is disorderly

such as: {' name ': ' Wupeiqi ', ' Age ': 18}, {' Host ': ' 2.2.2.2 ', ' Port ': 80]}

PS: When looping, the default loop key

Each dictionary has the following features:

To create a dictionary:
123 person  =  < Code class= "Python plain" >{ :  "Mr.wu" ,  ' age ' :  18 or person  =  dict "Mr.wu" ,  :  18

Python Development "chapter II": Python Basics-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.