Python data type

Source: Internet
Author: User

A computer is a machine that can do mathematical calculations as the name implies, so a computer program can handle a variety of values. However, the computer can handle far more than the numerical value, but also can deal with text, graphics, audio, video, web and other kinds of data, different data, need to define different data types. In Python, there are several types of data that can be processed directly:

One, integer

Python can handle integers of any size, including, of course, negative integers, and in a Python program, integers are represented in exactly the same way as mathematically, for example:,,, 1 100 , and so on -8080 0 .

Because the computer uses binary, it is sometimes convenient to use hexadecimal notation for integers, and hexadecimal is 0x represented by prefixes and 0-9,a-f, for example: 0xff00 ,, and 0xa5b4c3d2 so on.

Second, floating point number

Floating-point numbers, which are decimals, are called floating-point numbers because, when represented by scientific notation, the decimal position of a floating-point number is variable, for example, 1.23x10^9 and 12.3x10^8 are equal. Floating-point numbers can be written in mathematical notation, such as,, 1.23 3.14 , and -9.01 so on. But for very large or very small floating-point numbers, it must be expressed in scientific notation, the 10 is replaced with E, 1.23x10^9 is 1.23e9, or 12.3e8,0.000012 can be written 1.2e-5, and so on.

Integers and floating-point numbers are stored inside the computer in different ways, and integer operations are always accurate (is division accurate?). Yes! ), and the floating-point operation may have rounding errors.

Three, string

Strings are ‘‘ arbitrary text in or around "" them, such as ' abc ', ' XYZ ', and so on. Note that the ' or ' itself is only a representation, not part of a string, so the string has ‘abc‘ only a,b,c these 3 characters.

Four, Boolean value

A Boolean value is exactly the same as a Boolean algebra, with a Boolean value of only True False two values, either, True or, False in Python, you can directly use True and False represent a Boolean value (note case). It can also be computed by Boolean operations.

Boolean values can be used and , or and not operations.

    andOperations are associated with operations, and only the results of all true,and operations are True.

    orAn operation is or an operation, as long as one of the true,or operation results is True.

    notAn operation is a non-operation, which is a single-mesh operator that turns true into False,false to true.

Five, null value

A null value is a special value in Python, None denoted by. None cannot be understood as 0, because 0 is meaningful, and none is a special null value.

Note: The above content transferred from MU-class network, only for individual learning!

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.