Home >Backend Development >Python Tutorial >The difference between / and // in Python
The difference between / and // in Python
In Python, "/" represents floating point division and returns a floating point result, that is The result is a floating point number, and "//" means integer division in Python, returning the largest integer that is not greater than the result, which means that the division result is rounded down.
Code
print("6 // 4 = " + str(6 // 4)) print("6 / 4 =" + str(6 / 4))
Result
6 // 4 = 1 6 / 4 =1.5
Python arithmetic operators
Operator | Description | Instance |
---|---|---|
Add-Add two objects | a b Output result 30 | |
- | Subtract-Get a negative number or subtract one number from another Number | a - b Output result -10 |
* | Multiply - Multiply two numbers or return a character that is repeated several times String | a * b Output result 200 |
/ | division - x divided by y | b / a Output result 2 |
% | Modulo - Returns the remainder of division | b % a Output result 0 |
** | Power - Returns the y power of x | a**b is 10 raised to the 20th power, and the output result is 100000000000000000000 |
// | Take integer division - Return the integer part of the quotient (Round down) | >>> 9//24>>> -9//2-5 |
Recommended tutorial : "Python Tutorial"
The above is the detailed content of The difference between / and // in Python. For more information, please follow other related articles on the PHP Chinese website!