Python's number types are:
Int,long,float,complex,bool (0:false, 1:true)
There is no size limit for python integers, and integers for some languages are limited by size depending on their storage length.
Computer because of the use of binary, so, sometimes hexadecimal notation is more convenient, hexadecimal with 0x prefix and 0-9,a-f, for example: 0XFF00,0XA5B4C3D2, etc.
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.23x109 and 12.3x108 are exactly equal. For large or very small floating-point numbers, it must be expressed in scientific notation, the 10 is replaced with E, 1.23x109 is 1.23e9, or 12.3e8,0.000012 can be written as 1.2e-5. Python has no size limit for floating-point numbers, but is directly represented as INF (infinity) beyond a certain range
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.
Common methods for type int
>>> Help (int)
Methods defined here:
__abs__ (self,/)--Take absolute value
ABS (self)--
>>> age=-18
>>> age.__abs__ ()
18
>>> ABS (age)-perform built-in functions abs () is actually called the int.__abs__ method
18
Bit_length (...)
Int.bit_length () int--Get the length of the int store
>>> Bin (37)
' 0b100101 '
>>> (PNS). Bit_length ()
6
__divmod__ (self, value,/)--seeking quotient and remainder
Return Divmod (self, value). --self for Divisor
>>> age=9
>>> age.__divmod__ (2)
>>> Divmod (9,2)
(4, 1)
__rdivmod__ (self, value,/)
Return Divmod (value, self). --self to Dividend
Use: Divmod can be used for paging, such as a total of 95 records, 10 per page, how many pages?
__float__ (self,/)--Convert to floating point
Float (self)
__int__ (self,/)-constructs a method that automatically triggers this method when an object is created
int (self)
Number type of Python data type