What is the purpose of the `//` operator in python?

PythonServer Side ProgrammingProgramming

In Python, // is defined as floor division operator. It returns integer part of a floating point result of division. For example 10//3 returns 3

>>> 10//3
3
>>> 125.5//2.5
50.0
>>> 12.5//1.5
8.0

However in case of negative division, returned value is rounded towards negative infinity.

>>> -10//3
-4
>>> -73//9
-9
raja
Published on 14-Feb-2018 18:22:54
Advertisements