Python's // operator performs "floor division" (a.k.a. "integer division"). It always rounds down the result to the nearest integer while dividing.
Table of contents
The / operator
The / operator is the division operator in Python.
When / is used between two numbers, you'll always get the exact (as exact as Python can manage) result back:
>>> 5/22.5>>> 5/22.5Unlike some programming languages, / in Python does not act any differently when used between integers; in Python 3 that is.
In Python 2, division between two integers would would the result downward to the nearest integer:
>>> 5/2# Python 22>>> 5/2# Python 22But in Python 3, division between two integers always returns a floating point number with the exact result:
>>> 4/22.0>>> 4/22.0The // operator between integers
The // operator is the …