Python data type

Source: Internet
Author: User

Basic data types

1. Digital

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

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.

Float (float type)

Working with real numbers, which are numbers with decimal points

2. Boolean value

True or False

1 or 0

3. String

" Hello World "

String Common functions:

    • Remove whitespace
    • Segmentation
    • Length
    • Index
    • Slice

4. List

To create a list:

1 name_list = ['DD','one',' boy ' ' ]2# or 3 name_list = list (['DD' ,'one','boy')

Basic operation:

Index

Slice

Additional

Delete

Length

Cycle

Contains

5, Ganso

To create a meta-ancestor:

1 dd = (11,22,33,44)2# or 3 DD = tuple ((11,22,33,44))

Basic operation:

Index

Slice

Cycle

Length

Contains

6. Dictionary (unordered)

To create a dictionary:

1person = {"Key":"value","name":" -"}2 #or3Person = Dict ({"Key":"value","name":" -"})

Common operations:

Index

New

Delete

Key, value, key-value pairs

Cycle

Length

7. Set Set

Set set, which is an unordered and non-repeating collection of elements

View Code

Operator

1. Arithmetic arithmetic

2. Comparison operation

3. Assignment operation

4. Logical operation

5. Member arithmetic

Other

1. For loop

Iterates through the contents of an object in order,

Ps:break, continue

DD = [11,22,33] for in DD:    print(i)

2, Enumerate

Add an ordinal to an iterative object

1 dd = [11,22,33]2 for in Enumerate (DD, 1):3     Print(k,v)

3. Range and Xrange

Specify a range of values to generate the specified number

Python data type

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.