Python data type

Source: Internet
Author: User

One, integer

1, Python can handle an arbitrary size of integers, of course, including negative integers, in the Python program,

Representation of integers The method is exactly the same as the mathematical notation, for example: 1,100,200,-480 and so on.

2, you can also use the hexadecimal way to represent an integer, for example: 0x123, 0xFF, and so on.

Second, floating point number

1, floating-point number is a decimal, the reason is called floating point, because in accordance with 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 used in mathematical notation, such as 1.3, 20.1, 2.31, 8.5, and so on. But for very large or very small

Floating-point number, it must be expressed in scientific notation, for example: 1.23x10^9 = 1.23e9,

1.23x10^8 = 1.23e8 and so on. In Python, you can use mathematical notation as well as

Scientific notation to represent a floating-point number, for example: "print-5.2", "Print 1.23e9", and so on.

2, integers and floating-point numbers are stored inside the computer in a different way, and integer arithmetic is always accurate.

(IS division also accurate?) Yes! ), and the floating-point operation may have rounding errors.

Three, string

A string is any text enclosed in "or", such as ' abc ', ' XYZ ', and so on. This is the Shell scripting language.

The representation of a string is very similar, and "and" itself is not part of the string.

Four, Boolean value

1, Boolean and Boolean algebra are fully consistent, a Boolean value only true, false two kinds of values, or

is true, or false, in Python, the Boolean value can be expressed directly with true and False (please note case),

It can also be computed by Boolean operations.

2. Logical operators

(1) and (with): print (1 > 0) and (1 > 2) The result is: False

Print (1 > 0) and 100 results are: 100

Print + (1 > 0) The result is: True

(2) or (or): print (1 > 0) or (1 > 2) result is: True

Print (1 < 0) or (1 > 2) result is: False

Print or (0 > 1) The result is: 100

(3) Not (non): Turns false to True, turns true to False

Print not False The result is: True

Print not True The result is: False

Print not 100 results are: False

Five, null value

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. In addition, Python provides a variety of data types such as lists, dictionaries, etc., and also allows you to create

Define the data type, which we'll continue to talk about later.

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.