Python division // operator is confused when learning python. In this tutorial, we will use an example to help you understand it.
Look at this example below:
i = 11 / 3 print(i) i = 12 / 3 print(i) i = 11 //3 print(i) i = 11.0 // 3.0 print(i)
In python 3.5, the result is:
3.6666666666666665 4.0 3 3.0
From the result, we can find:
- / operator is a real division, the result is a float number.
- // operator will return the integer part of the result, if the result is integer, // operator will return integer, otherwise, it will return a float number.