No matter what language is inseparable from subtraction these algorithms, but in Python you know what these symbols represent?
"/" This is the division operation, then this "//"? "*" This is the multiplication, then this "* *"? Here are some of the following.
"//" operation
The division operator is "/", which is known to all, but the result of this two-dollar operator "/" is determined by the operand itself, such as:
Copy the Code code as follows:
20/3
6
20/3.0
6.666666666666667
20.0/3
6.666666666666667
20.0/3.0
6.666666666666667
That is, when using the "/" operator, as long as an operand is a floating-point number, then the result is a floating-point result, which we call the true divide, but if the two operands are integers, then the result is an integer number of decimal digits, which we call the divisible. But if this is the case, no matter the operand is an integer, the floating-point number of God horse, I want the result is evenly divisible, then "//" comes in handy, this "//" is to solve the problem.
"//" is starting with Python2.2, and the division operator, in addition to "/", introduces a division operator, an operator that is used only to divide the method, as in the following example:
Copy the Code code as follows:
20//3
6
20//3.0
6.0
20.0//3
6.0
20.0//3.0
6.0
20//3.00
6.0
Regardless of the operand, the result of "//" is evenly divisible, and if the operand is a floating-point number, it is returned to us as a result of dividing the integer into floating point.
"* *" operation
This "* *" is relatively simple, is the title of the power of the Python operation, the demo is as follows:
Copy the Code code as follows:
2 * * 0
1
2 * * 1
2
2 * * 10
1024
2 * * 20
1048576
The first operand is the base, and the second operand is the exponent.
Finish ~