Python Tour-python Basics 4-Data type

Source: Internet
Author: User

1. Digital

2 is an example of an integer. Long integers are just larger integers, and 3.23 and 52.3E-4 are examples of floating-point numbers. The e tag represents a power of 10. Here, 52.3E-4 means 52.3 * 10-4.

( -5+4j) and (2.3-4.6j) are examples of complex numbers, where -5,4 is a real number, j is an imaginary number, and what is the plural in mathematics?

    • int (integral type)

      On a 32-bit machine, the number of integers is 32 bits and the value range is "231~2 32-1", i.e. -2147483648~2147483647

      On a 64-bit system, the number of integers is 64 bits and the value range is 263~263-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.

      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 the Long data.

    • 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 bytes), where 52 bits represent the bottom, 11 bits represent the exponent, and the remaining one indicates compliance.

    • Complex (plural)

      The complex number consists of the real part and the imaginary tree part, the general form is X+yj, where x is the real part of the complex, and Y is the imaginary part of the complex, where x and y are real numbers.

      Note: Small number pools exist in Python: -5~257

2. Boolean values

True or False

1 or 0

3. String
“hello world”万恶的字符串拼接:  python中的字符串在C语言中体现为是一个字符数组,每次创建字符串时候需要在内存中开辟一块连续的空,并且一旦需要修改字符串的话,就需要再次开辟空间,万恶的+号每出现一次就会在内从中重新开辟一块空间。

String formatted output

name = "alex"print "i am %s " % name  #输出: i am alex

PS: string is%s; integer%d; floating-point number%f

String Common functions:

    • Remove whitespace
    • Segmentation
    • Length
    • Index
    • Slice

Python Tour-python Basics 4-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.