The 1.Python numeric data type is used to store numeric values.
The data type is not allowed to change, which means that if you change the value of the numeric data type, the memory space will be redistributed.
The 2.Python supports three different numeric types:
- Integer (Int) -usually referred to as an integer or integral, is a positive or negative integer, with no decimal points. The Python3 integral type is not limited in size and can be used as a long type, so Python3 does not have a long type of Python2.
- float (float) -floating-point type consists of integral and fractional parts, and floating-point types can also be represented using scientific notation (2.5e2 = 2.5 x 102 = 250)
- complex numbers ((complex)) -complex numbers are composed of real and imaginary parts, and can be represented by a + BJ, or complex (a, b), where both the real and imaginary part of a complex number are floating-point types.
3.Python Numeric Type conversions
Sometimes, we need to convert the data-built type into the data type, and you just need to use the data type as the function name.
int (x) converts x to an integer.
float (x) converts the x to a floating-point number.
Complex (x) converts x to a complex number, the real part is x, and the imaginary part is divided into 0.
complex (x, y) converts x and y to a complex number, the real part is x, and the imaginary part is Y. X and y are numeric expressions.
4.Python Digital Arithmetic
The Python interpreter can be used as a simple calculator, and you can enter an expression in the interpreter that will output the value of the expression.
The syntax of an expression is straightforward: +,-, * and/and other languages (such as Pascal or C).
A variable must be "defined" (that is, given a variable value) before it can be used, or an error will occur:
Note: 1. converting integers into floating-point numbers when mixing operations of different types:
2. In interactive mode, the result of the last expression output is assigned to the variable _ .
3._ variables should be treated as read-only variables by the user.
5. Related functions: Mathematical functions, random number functions, trigonometric functions, mathematical constants.
Python3 Digit (number)