Let's talk about several common data types in Python and python data types.
As the name suggests, a computer is a machine that can be used for mathematical computation. Therefore, a computer program can naturally process various numerical values. However, computers can process a variety of data, such as text, graphics, audio, video, and web pages. Different data types need to be defined. In Python, the following types of data can be processed directly:
I. Integer
Python can process Integers of any size, including negative integers. in Python, the expression of integers is the same as that in mathematics, such as 1,100,-80, and 0.
Because the computer uses binary, it is convenient to use the hexadecimal notation to represent integers. The hexadecimal notation is indicated by the 0x prefix and 0-9, a-f, for example, 0xff00, 0xa5b4c3d2, and so on.
Ii. Floating Point Number
A floating point is also a decimal point. It is called a floating point because the decimal point position of a floating point is variable according to the scientific notation. For example, 1.23x10 ^ 9 and 12.3x10 ^ 8 are equal. Floating point numbers can be written in mathematics, such as 1.23, 3.14,-9.01, and so on. However, large or small floating point numbers must be represented by scientific notation, replacing 10 with e. 1.23x10 ^ 9 is 1.23e9, or 12.3e8, 0.000012 can be written as 1.2e-5.
Integers and floating-point numbers are stored in computers in different ways. Integer operations are always accurate (is Division accurate? Yes !), Floating-point operations may have rounding errors.
Iii. String
A string is any text enclosed by ''or" ", such as 'abc' and" xyz. Note that ''or" "is only a representation, not a part of the string. Therefore, the string 'abc' contains only three characters: a, B, and c.
Iv. Boolean Value
The Boolean value is exactly the same as that of the Boolean algebra. A boolean value can only be True or False, either True or False. in Python, values of True and False can be used to represent boolean values (case-sensitive) or computed using Boolean operations.
Boolean values can be calculated using and, or, and not.
The and operation is an operation. Only True is used for all operations, and True is used for all operations.
Or is an or operation. If either of them is True, or is True.
The not operation is not an operation. It is a single-object operator that converts True to False and False to True.
5. null values
A null value is a special value in Python, expressed as None. None cannot be understood as 0, because 0 is meaningful, and None is a special null value.
In addition, Python provides multiple data types, such as lists and dictionaries, and allows you to create custom data types.