Data types in Python

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:
    1. 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,-8080,0, and so on.
    2. Computer because of the use of binary, so, sometimes hexadecimal notation is more convenient, hexadecimal with 0x prefix and 0-9,a-f, such as: 0XFF00,0XA5B4C3D2, and 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,-9.01, and 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 enclosed in ' or ', such as ' abc ', ' XYZ ', and so on. Note that the ' or ' itself is only a representation, not a part of the string, so the string ' abc ' only a,b,c these 3 characters.

Four, Boolean value

    1. The Boolean value is exactly the same as the Boolean algebra, with a Boolean value of only true, false two, or true, or false, in Python, which can be used to indicate a Boolean value directly with True, false (note case), or by Boolean operations.
    2. Boolean values can be operated with and, or, and not.
    3. The and operation is associated with an operation, and only the result of all true,and operations is True.
    4. An OR operation is an operation, as long as one of the true,or operation results is True.
    5. The not operation is a non-operation, which is a single-mesh operator that turns true to False,false to true.

five, null value

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

eq:

operators in Python 1. comparison Operators _cmp_ (Self,other) contains all the cases of two objects compared _eq_ (Self,other) to determine two objects of equal _lt_ (self,other) less than _gt_ (Self,other) greater than 2. Digital Operations _add_ (self,other) plus _sub_ (self,other) minus _mul_ (self,other) Multiply _div_ (self,other) except     3. Logical Operation       _or_ (self,other) or  _and_ (self,other) and

See If you can see the little buddy. http://note.youdao.com/noteshare?id=14d77924998623003222cb7c32bf5ea6&sub= 5c0a4aeaa7a446f5834f12b951bb5152  

Data types in Python

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.