In Python, double forward slash (//
) is used for floored division, which means:
- Numbers are divided first, and then;
- Rounded down (or floored) to the nearest integer.
Using x // y
is equivalent to floordiv(x, y)
.
You can draw the comparison between true division and floored division in the following examples:
// floored division num = 9 // 5 print(num) # 1 print(type(num)) # <class 'int'>
// division num = 9 / 5 print(num) # 1.8 print(type(num)) # <class 'float'>
Hope you found this post useful. It was published . Please show your love and support by sharing this post.