Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What data types are there in python?
What data types are there in python?
There are many python data types. Here are some simple examples:

The first type: integer

Python can handle integers of any size, including negative integers. In python programs, the expressions of integers are exactly the same as the mathematical expressions, such as: 1, 100,-8080,0 and so on.

Because computers use binary, it is sometimes convenient to represent integers in hexadecimal, with 0x prefix and 0-9, a-f, for example, 0xff00.

The second type: floating point number

Floating-point numbers, that is, decimals, are called floating-point numbers because the decimal point position of floating-point numbers is variable when expressed according to scientific counting methods. Floating-point numbers can be mathematically written as 1.23, 3. 15, -9.05438+0, etc. But for very large or very small floating-point numbers, it must be expressed by scientific counting methods. Replace 10 with e, 1.23x 10 9 is1.23e9.

Integers and floating-point numbers are stored differently in computers. Integer operations are always accurate, while floating-point operations may have rounding errors.

The third type: string

A string is any text enclosed by "or", such as "abc" and "xyz". Please note that "or" itself is only a representation, not a part of the string, so the string "‘ABC'" has only three characters: A, B and C.

Fourth: Boolean value

The representation of Boolean value and Boolean algebra is completely consistent. Boolean values have only two values, true or false. In python, it can be directly expressed by true or false, and can also be calculated by Boolean operation.

Boolean values can be operated with and, or or not.

The and operation is an and operation, and the result of the AND operation is true only when everything is true.

The or operation is the or operation. As long as one of them is true, the result of the OR operation is also true.

Non-operation is non-operation, which is a monocular operator, turning truth into falsehood and falsehood into truth.

Fifth: null value

Null value is a special value in python, which is represented by None. None cannot be understood as 0, because 0 is meaningful and None is a special null value.

In addition, python provides various data types, such as lists and dictionaries, and allows you to create custom data types.