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,-8080,0, and so on.
- 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
- 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.
- Boolean values can be operated with and, or, and not.
- The and operation is associated with an operation, and only the result of all true,and operations is True.
- An OR operation is an operation, as long as one of the true,or operation results is True.
- The not operation is a non-operation, which is a single-mesh operator that turns true to False,false to true.
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.
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