"//" operation
The division operator is "/", which is known to all, but the result of this two-dollar operator "/" is determined by the operand itself.
20/3
6
20/3.0
6.666666666666667
20.0/3
6.666666666666667
20.0/3.0
6.666666666666667
When using the "/" operator, as long as an operand is a floating-point number, 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 division. 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. Codego.net programming code provided.
"//" is starting from Python2.2, and the division operator, in addition to "/", introduces a division operator, which is used only to divide the method,
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, that is, the power of Python in the title
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.
This article is from the "iioios8l" blog, make sure to keep this source http://10068344.blog.51cto.com/10058344/1629052
Python Division and Power Operation code examples